Okay so, I was making a shop gui for my game and I made it so that when you click a button it gives you a tool for a certain amount of currency that I also added into my game. But the problem is, when you buy the tool you the person who's holding the tool can see it, but other players can't see the tool that you're holding.
I'm not sure if this is a bug or if I put something wrong in my script, but heres my script.
local player = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function(click) if player.leaderstats.Points.Value >= 50 then player.leaderstats.Points.Value = player.leaderstats.Points.Value - 50 game.ReplicatedStorage.Tools.Flashlight:Clone().Parent = player:WaitForChild("Backpack") end end)
I also have another tool with the same script but its a taco.
Thats because the tool is not being replicated to server, you need to clone it and change leaderstats value via serverscript, or it will only change for localplayer
To add on to what Leamir said, you need to do it on the server;
Add a remoteevent to ReplicatedStorage and a serverscript in the serverscriptservice,
Name the RemoteEvent whatever, let's say we name it 'RE'.
In the localscript above, you call the event, like so
local event = game:GetService("ReplicatedStorage"):WaitForChild("RE") event:FireServer()
Then in the server script you can put
local event = game:GetService("ReplicatedStorage"):WaitForChild("RE") event.OnServerEvent:connect(function(player) --when firing from client to server the first parameter will always be player --Do stuff in here, clone the tool, anything you do will be replicated across the server end)
Remember that exploiters can fire your remote event, so do your checks before executing the code on the server.