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

How can I move the cloned tool to the player's backpack ?

Asked by 6 years ago

I want to make my own giver, I think I've done the basics (I tested it out a slight bit different way to spawn a car, worked), but I'm struggling to get the tool to the player's Backpack who cloned it.The script is a LocalScript

Here's what I've done:

local Button = script.Parent
local Flashlight = game.ServerStorage.NATMFlashlight
local Inventory = game.Players.LocalPlayer

function OnClicked()
    CopyBoy = Flashlight:Clone()
    CopyBoy.Parent =  Inventory.Backpack
end

Button.ClickDetector:connect(OnClicked)
0
Local Scripts cannot access the ServerStorage. Only regular scripts can do that. Also, a Local Script cannot function in the Workspace. I will put the correct code below. UgOsMiLy 1074 — 6y
0
Thanks ! LordTechet 53 — 6y

1 answer

Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago
Edited 6 years ago

"ClickDetector" is not an event. The event that fires when it is clicked is "MouseClick", and must be handled by a server script.

Put this code in a Script (not a LocalScript) inside the "Button"

local Button = script.Parent
local Flashlight = game.ServerStorage.NATMFlashlight

function OnClicked(Inventory) -- The player that clicked is a parameter to the function.
    CopyBoy = Flashlight:Clone()
    CopyBoy.Parent =  Inventory.Backpack
end

Button.ClickDetector.MouseClick:Connect(OnClicked)
Ad

Answer this question