I want to create a tool that is when is clicked it deletes itself and replicates another tool in the user's backpack. No matter what I do it does not work. What am I doing wrong?
Here is my script here: ( local script)
local tool = script.parent;
x = game.Players.LocalPlayer.Backpack z = game.Lighting:WaitForChild("Cookie"):clone()
function onActivated() z.Parent = x tool: Destroy () end
tool.Activated:connect(onActivated)
Well, from my experience, you do not have to use:
local tool = script.Parent;
If it is in a local script
I also think that the ; in this is not suppose to be there
local tool = script.Parent
if it doesn't work I don't know then.
Try a wait() between z.Parent = x and tool:Destroy() Are you sure z is in lighting? You can try like
repeat wait (.1) until game.Lighting:FindFirstChild("Cookie")
Are you sure that z is not nil?