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 fix this script?

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

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?

3 comments

0

What do you mean?

0

What exactly is failing to work? Is there no tool when the tool activates or..?

0

There is no tool replicated when activated.

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