The script is in a text button, and there is an IntValue in the button. (for the cost) It works with local script, but won't seem to show on other players screens, or run any scripts within it. Can someone help?
player = game.Players.LocalPlayer DP = player.leaderstats.DamagePoints price = script.Parent.Cost.Value tool = script.Parent:FindFirstChild("UpgradedSword") function buy() if DP.Value >= price then DP.Value = DP.Value - price local a = tool:clone() a.Parent = player.Backpack local b = tool:clone() b.Parent = player.StarterGear end end script.Parent.MouseButton1Down:Connect(buy)
I had this same issue, you need to use a remote event with a server script to do this. Add a remote event to replicatedstorage called "fire"
Local Script:
script.Parent.MouseButton1Down:Connect(function() game.ReplicatedStorage.Fire:FireServer()
Server Script
DP = player.leaderstats.DamagePoints price = script.Parent.Cost.Value tool = script.Parent:FindFirstChild("UpgradedSword") game.ReplicatedStorage.Fire.OnServerEvent:Connect(function(player) if DP.Value >= price then DP.Value = DP.Value - price local a = tool:clone() a.Parent = player.Backpack local b = tool:clone() b.Parent = player.StarterGear end end)
If I helped please accept this answer!