Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't tools show for other players but only for the person whos holding the tool?

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.

2 answers

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.

3 comments

0

ohhhh okay! tysm!

0

wait im still very confused, how would I set everything up? I'm really new to this whole scripting stuff.

0

so do I add a local script to replicated storage and a regular script to serverscriptservice?

This discussion is preserved as it was. New answers, comments, and votes are closed.