if points < 500 then --Checks player leaderstats for amount of points
confirm.ConfirmTitle.Text = "INSUFFICIENT POINTS" --Warns player to get more
elseif game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats"):GetAsync("HasMegaSword") == false then --If the DataStore has no records of the Mega Sword being purchased then
local bool = true
game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats"):SetAsync("HasMegaSword", bool) --Set a record of the item being purchased
points = points - 500 --Deduct
--The following gets rid of the ClassicSword and replaces it with the Mega Sword.
if player.Backpack:FindFirstChild("ClassicSword") then
player.Backpack.ClassicSword:Destroy()
c = store.MegaTools.MegaSword:clone()
c.Parent = player.Backpack
elseif player.Character:FindFirstChild("ClassicSword") then
player.Character.ClassicSword:Destroy()
c = store.MegaTools.MegaSword:clone()
c.Parent = player.Backpack
end
confirm.ConfirmTitle.Text = "ITEM PURCHASED" --Warn the player
else
confirm.ConfirmTitle.Text = "ITEM ALREADY BOUGHT" --There was already a record of the item being bought, so warn the player
end
All of this SHOULD work, right? Any ideas to get it fixed?
Link to game: http://www.roblox.com/games/177080409/Vehicle-Mayhem-CTF-v1-3
I only added the DataStore part to avoid paying for the item twice and being able to automatically load the item when joining the game. For now, I disabled this until it can be fixed.