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

How do I fix this script?

Asked by 8 years ago

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)

3 answers

Log in to vote
1
Answered by 8 years ago

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.

Ad
Log in to vote
0
Answered by
beader 0
8 years ago

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")

Log in to vote
-1
Answered by 8 years ago

Are you sure that z is not nil?

0
What do you mean? TheFlashIsFast 0 — 8y
0
What exactly is failing to work? Is there no tool when the tool activates or..? adoScripting 0 — 8y
0
There is no tool replicated when activated. TheFlashIsFast 0 — 8y

Answer this question