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

Click to remove tool? (Still not answered)

Asked by
Rdumb1 4
5 years ago
Edited 5 years ago

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()
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? User#24928 0 — 5y
0
Yeah.. I couldn't think of anything else trying to remove the item when clicked. Rdumb1 4 — 5y
0
Instead, it justs deletes the spawned ally if you put the line in. Rdumb1 4 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
0
will this be local or normal script? Rdumb1 4 — 5y
0
Normal is the only way AidanTES 36 — 5y
0
If you use a local script 1. The tool won't destroy for others 2. The NPC will not spawn AidanTES 36 — 5y
0
Where do I put the script? Rdumb1 4 — 5y
View all comments (13 more)
0
Inside your tool which should be in the starter pack AidanTES 36 — 5y
0
If this worked please press accept answer below! ;) AidanTES 36 — 5y
0
So I put script in the recruit tool, but doesn't disappear.. I tried the 2nd Variation too. Rdumb1 4 — 5y
0
Are you trying in studio or in the game itself? Sometimes it doesn't work in studio AidanTES 36 — 5y
0
what you should do is upload the game and make it private AidanTES 36 — 5y
0
Do you have FE? (Filtering Enabled) check in workspace's properties if yes switch it off AidanTES 36 — 5y
0
Its a 1 player game, and it is private. And some scripts may not work without fe.. Rdumb1 4 — 5y
0
all scripts work without fe some scripts don't work with fe AidanTES 36 — 5y
0
and I'm testing it on studios. Rdumb1 4 — 5y
0
And um.. It doesn't work ingame without fe. Rdumb1 4 — 5y
0
*does not work on both fe and not fe Rdumb1 4 — 5y
0
Test it in game AidanTES 36 — 5y
0
Nope, still doesn't work. Rdumb1 4 — 5y
Ad

Answer this question