Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Click to remove tool? (Still not answered)

Asked by
Rdumb1 -12
13 days ago
Edited 13 days 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? proGamergirl2468 30 — 13d
0
Yeah.. I couldn't think of anything else trying to remove the item when clicked. Rdumb1 -12 — 13d
0
Instead, it justs deletes the spawned ally if you put the line in. Rdumb1 -12 — 13d

1 answer

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

Answer this question