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

How do I clone a tool to a player using a GUI?

How do I clone a tool to the player using a GUI? I'm making an admin panel that has options to select tools, but I don't know how to script it correctly. I tried the code in both a LocalScript and Script. Both didn't work, is there something I'm doing incorrectly? Here's my code, for you to correct it:

-- This is a LocalScript inside of a GUI button -- 
script.Parent.MouseButton1Click:Connect(function(plr)
	local Taser = game.ServerStorage.Taser:Clone()
	Taser.Parent = plr.Backpack
end)

I also tried doing

local plr = game.Players.LocalPlayer

but to no avail. Please help!

2 comments

0

LocalScripts cannot access ServerStorage, that container belongs to the opposite end of the Network. ServerScripts don't operate in local environments, they're not meant to control the Client; you're facing a FE conflict, to successfully achieve your goal, you'll need to apply RemoteEvents.

0

You can also just put your tools in the Replicated Storage instead of Server Storage.

2 answers

For one, you're identifying an object to the script ending with an action: local Taser = game.ServerStorage.Taser:Clone()

It should be: local Taser = game.ServerStorage.Taser

Try local plr = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function(plr) local Taser = game.ServerStorage.Taser Taser:Clone().Parent = plr.Backpack end)

Wont necessarily solve your problem but here's hoping. :)

just move it into ReplicatedStorage, also players wont see tool when its cloned with local script

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