WHAT DID I DO WRONG, WHEN I PRESS IT IT'S SUPPOSED TO GIVE ME A GRAVITY COIL?! PLEASE TWEAKKKKK.
script:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function(click) if player.leaderstats.High Score.Value >= 1 then player.leaderstats.High Score.Value = player.leaderstats.High score - 1
game.ReplicatedStorage.Tools.GravityCoil:clone().Parent = player:WaitForChild("Backpack") end
end)
So. You need to use Remote Events. Because if you're working with GUIs, they have to be LocalScript since they have to be replicated to the PlayerGui. So we're gonna use FireServer() in order to send information. (Make sure your script is below the ScreenGui.)
Local Script
script.Parent.ImageButton:Connect(function() local player = game.Players.LocalPlayer if player.leaderstats["High Score"].Value >= 1 then game.ReplicatedStorage.RemoteEvent:FireServer(player) end end)
Now we just passed data. We only need the player property.
Server Script
game.ReplicatedStorage.OnServerEvent:Connect(function(player) player.leaderstats["High Score"].Value = player.leaderstats["High Score"].Value - 1 local tool = game.ReplicatedStorage.Tools.GravityCoil local toolClone = tool:Clone() toolClone.Parent = player.Backpack end)