Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Click to remove tool? (Still not answered)

So I'm making a game, with recruiting npc allies to help you fight. I found this model id spawner for example: I clicked when using the tool and it spawns an ally. But I can't find a way to remove it when I clicked once. I am also not experienced with scripting so I don't know how to.

I just did this at the end of the spawn model script

local function OnClick:Delete()

3 comments

0

just that at the end of the spawn model script? Just that? all you did was made a function. In fact by the looks of it you barley even made the function. Let alone calling the function. Is there anything else? at all?

0

Yeah.. I couldn't think of anything else trying to remove the item when clicked.

0

Instead, it justs deletes the spawned ally if you put the line in.

1 answer

First you have to make the variable for the tool

local tool = game.StarterPack.Tool -- Replace tool with the name of your tool

Then you have to start with a proper function:

function(onClick)

end

tool.Activated:Connect(onClick)

Add this in the inside the function:

tool:Destroy()

All together now:

local tool = game.StarterPack.Tool -- Replace tool with the name of your tool

function(onClick)
   tool:Destroy()
end

tool.Activated:Connect(onClick)

2nd Variation:

local tool = game.StarterPack.Tool -- Replace tool with the name of your tool

tool.Activated:Connect(function(onClick)
   tool:Destroy()
end)

17 comments

0

will this be local or normal script?

0

Normal is the only way

0

If you use a local script 1. The tool won't destroy for others 2. The NPC will not spawn

0

Where do I put the script?

0

Inside your tool which should be in the starter pack

0

If this worked please press accept answer below! ;)

0

So I put script in the recruit tool, but doesn't disappear.. I tried the 2nd Variation too.

0

Are you trying in studio or in the game itself? Sometimes it doesn't work in studio

0

what you should do is upload the game and make it private

0

Do you have FE? (Filtering Enabled) check in workspace's properties if yes switch it off

0

Its a 1 player game, and it is private. And some scripts may not work without fe..

0

all scripts work without fe some scripts don't work with fe

0

and I'm testing it on studios.

0

And um.. It doesn't work ingame without fe.

0

*does not work on both fe and not fe

0

Test it in game

0

Nope, still doesn't work.

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