I was scripting tool giver gui but its working but other players cant see the tool when equiped. I have alredy gui but i think issue is its in local script that gives tool when gui is clicked. So i tried change local script to script and still not working. So the tool giver is not working.
So i dont know how to make it the tool visible for all players when equipped so please help because i have no idea how to solve this issue.
Script what i used:
local tool = game.ReplicatedStorage.Food.Salad
local button = script.parent
local plr = game.Players.LocalPlayer
button.MouseButton1Click:Connect(function()
tool:Clone().Parent = plr.Backpack
end)
local Button = script.Parent
local Salad= game.ReplicatedStorage.Food.Salad
local Player = game.Players.LocalPlayer
Button.MouseButton1Click:Connect(function()
local SaladClone = Salad:Clone()
SaladClone.Parent = Player.Backpack
end)
You shouldnt do this on the client, use remote events. For example, if a player clicks the button, it will fire a server event and then a server script listening to that event would give the player his tool.
local button = script.Parent
local salad = game.ReplicatedStorage.Food.Salad
local plr = game.Players.LocalPlayer
local saladEvent = -- Your event path here
button.MouseButton1Click:Connect(function()
saladEvent:FireServer()
end)
local button = script.Parent
local salad = game.ReplicatedStorage.Food.Salad
local plr = game.Players.LocalPlayer
local saladEvent = -- Your event path here
button.MouseButton1Click:Connect(function()
saladEvent:FireServer(salad)
end)
Server Script
local saladEvent = -- Your event path here
saladEvent.OnServerEvent:Connect(function(plr, tool)
local toolClone = tool:Clone()
toolClone.Parent = plr.Backpack
end)
This should give you some knowledge on server side and client side:
LocalScripts will run on a player’s computer. So, when you see a game with a GUI, opening that GUI is done by a LocalScript, since it only opens for that player.
Server scripts are scripts that run on the server, meaning it effects everyone and everything on the server. This means, to give a player a tool that’s visible to the rest of the server, you need to use a RemoveEvent.
Just remember it’s better to understand the code than to copy it. Try to play around with the script rather than just pasting it and admiring what it does.
On the devforum we’re not normally allowed to give you code, but since people already have you may as well learn off of it.