Please help make it so this script first checks leaderboard stats to see if you have enough money or more then take that amount and finish the rest of the code (please do not make it so it gives the item i just need it so it checks if player has enough money and takes that amount!)
script.Parent.MouseButton1Click:connect(function() if not game.Players.LocalPlayer.Backpack:FindFirstChild("SpeedCoil") then print("Giving "..game.Players.LocalPlayer.Name.." Item.") Sword = game.Lighting.SpeedCoil:Clone() Sword.Parent = game.Players.LocalPlayer.Backpack elseif game.Players.LocalPlayer:FindFirstChild("SpeedCoil") then print(game.Players.LocalPlayer.Name.." Already received the item.") end end)
Thank you for your time! Please help me out!
Hello, thekittinking84!
All you have to do is pretty simple, so i have edited the script for you :)
local cost = 45 script.Parent.MouseButton1Click:connect(function() if not game.Players.LocalPlayer.Backpack:FindFirstChild("SpeedCoil") and game.Players.LocalPlayer.leaderstats.Money >= cost then -- Note : you have to place a folder named "leaderstats" with an IntValue named "Money" inside the folder, now the folder has to be inside the player ( not backpack ). game.Players.LocalPlayer.leaderstats.Money = game.Players.LocalPlayer.leaderstats.Money - cost print("Giving "..game.Players.LocalPlayer.Name.." Item.") Sword = game.Lighting.SpeedCoil:Clone() Sword.Parent = game.Players.LocalPlayer.Backpack elseif game.Players.LocalPlayer.Backpack:FindFirstChild("SpeedCoil") then print(game.Players.LocalPlayer.Name.." Already received the item.") end end)
Here, put this script in ServerScriptService :/
local stats = script.leaderstats:Clone() -- Make sure that you have done the things in the last note, but this time place the folder INSIDE this script, and you are done! game.Players.PlayerAdded:Connect(function(player) stats.Parent = player end)
-- Hope i helped.
--- Edited!
---- AIphanium