--For Example
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function(click) if player.leaderstats.Coins.Value >= 25 then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 25
game.ReplicatedStorage.Tools.GravityCoil:Clone().Parent = player:WaitForChild("Backpack") end
end)
Here.
Insert a remote event into ReplicatedStorage
and insert a local script into the buy button.
Local script:
script.Parent.MouseButton1Click:Connect(function() game.ReplicatedStorage.RemoteEvent:FireServer() end)
Now, insert a script into ServerScriptService
.
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player) local gravityCoil = game.ReplicatedStorage.Tools:WaitForChild("GravityCoil"):Clone() gravityCoil.Parent = player:WaitForChild("Backpack") end)
Please upvote and select this as your answer if it works.
this does not work because this is a local script and as such the tool will only appear on the client and not the server, you need to fire a remote event to make it appear on the server and client