Hi, Im trying to make a button that gives you a sword when you have enough money and reduces the Money leaderstat afterwards, but it doesnt work it gives the tool, but doesnt reduce the money.
local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() local cash = player.leaderstats.Money.Value if cash >= 50 then cash = cash - 50 game.Lighting.Sword:Clone().Parent = player.Backpack end end)
Hope someone can help me
local function OnClicked () if game.Players.LocalPlayer.leaderstats.Money.Value >= 50 then game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value - 50 local Sword = game.Lighting.Sword:Clone() Sword.Parent = game.Players.LocalPlayer.Backpack else return end end script.Parent.MouseButton1Click:Connect(OnClicked)
If this is filtering enabled, I would like to inform you that changing stats on local scripts won't work/replicate. As with cloning the sword, it won't replicate to the servers. If this is filtering enabled, I highly suggest you learn about remote events, make it so that when you click on the button, it fires the server where it can do the checks and cloning on the serverside. If this helped, be sure to accept answer as it gives us both +rep and marks the question answered. Report anything else in the comments. Learn about remote events here. https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events