Issue with tools showing only locally

Hello everyone!

so recently I’ve been working on scripting GUI’s, and I came across an issue.
so I made a script that clones a group of tools from ReplicatedStorage and put it inside the player’s Backpage, but since Gui’s only works with local scripts, it was a result of this (Look at {Local Error}).

Local Error


image

as you can tell, the tools ONLY show’s locally, which means that only the player that pressed the button in the GUI will be able to see the tools that he’s holding, while other players cant.

I can’t think of any way to fix this issue, I mean, I tried using normal scripts with GUI but of course, that won’t work.

More Information

image

-- local script
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	for i,v in pairs(game.ReplicatedStorage.RPTools:GetChildren()) do
		local RPS = v:Clone()
		RPS.Parent = Player.Backpack
	end
	script.Parent.Image = "http://www.roblox.com/asset/?id=5936753015"
	script.Parent.Remover.Disabled = false
	script.Disabled =true
end)

I hope there is a solution to this, thanks for your time.

Remote Events!

--local script in StarterGui
game.ReplicatedStorage.RemoteEvent:FireServer()
--serverscript in ui

function()
   script.Parent.MouseButton1Click:Connect(function()
	for i,v in pairs(game.ReplicatedStorage.RPTools:GetChildren()) do
		local RPS = v:Clone()
		RPS.Parent = Player.Backpack
	end
	script.Parent.Image = "http://www.roblox.com/asset/?id=5936753015"
	script.Parent.Remover.Disabled = false
	script.Disabled =true
   end)
end

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)
    function()
end)
2 Likes

aah yes, remote events.
I was thinking of using them altho I don’t know much about them, I ain’t an official scripter but I’m still learning.
anyways, I’ll try to use them, maybe watch a tutorial, thanks for your help.

1 Like

Remember to mark this as solved. ^^

1 Like