Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

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!

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. Ziffixture 6913 — 3y
0
You can also just put your tools in the Replicated Storage instead of Server Storage. Dr_Smartypants123 86 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

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. :)

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

Answer this question