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

On Click Destroy Parent? Very Confused Scripter

Asked by 5 years ago

I Am Trying To Make A Block That When You Click It It Gives You Cash And Destroys Itself. I Already Have It So It Gives You Cash, I Just Need The Destroy

1script.Parent.ClickDetector.MouseClick:connect(function(player) local players = game.Players:FindFirstChild(player.Name) local clicks = players:FindFirstChild("leaderstats")["Money"] clicks.Value = clicks.Value + 150 click.MaxActivatoinDistance = 0 wait (5) click.MaxActivatoinDistance = 5 end)
2script.Parent.ClickDetector.MouseClick:connect (Parent destroy)
0
lmao ur grammar is bad, and so is your spelling LoganboyInCO 150 — 5y
0
Imao You Should Be Reported For Bullying. Imao That Jerk. ricelicker 52 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago
Edited by User#24403 5 years ago

I just wanna say, please do some research before you ask a question, cause the mistake is kinda whack.

First of all, try to clean up your script so you can read it easily:

01local clickDetector = script.Parent.ClickDetector
02 
03clickDetector.MouseClick:Connect(function(player)
04    local clicks = player.leaderstats.Money
05    clicks.Value = 150
06    clickDetector.MaxActivationDistance = 0
07    wait(5)
08    clickDetector.MaxActivationDistance = 5
09end)
10 
11script.Parent.ClickDetector.MouseClick:Connect(Parent destroy)

. .

1script.Parent.ClickDetector.MouseClick:Connect(Parent destroy)

It's best to note the thing in the parenthesis is a parameter, and you cannot use regular words in it, you must use a Lua type.

So, you could make the parent nil (nothing) by typing:

1local function gone()
2 --whatever the block is
3    part.Parent = nil
4end
5 
6 script.Parent.ClickDetector.MouseClick:Connect(gone)

Now just put that at the end of the script and your finished. Hope you learned something!

Ad
Log in to vote
0
Answered by 5 years ago
01--------[[Defining Players]]--------------
02local Players = game:GetService("Players")
03 
04--------[[Defining ClickDetector]]-------------
05local clicker = script.Parent.ClickDetector
06    clicker.MaxActivationDistance = 0
07    wait(5)
08    clicker.MaxActivationDistance = 5
09 
10---------[[Set up the anti-spam click]]-----------
11local debounce = true
12 
13---------[[Wrapping the outcome in the click function]]------------
14clicker.MouseClick:Connect(function(player)
15 
View all 36 lines...
0
the spacing and indentation makes me wanna vomit LoganboyInCO 150 — 5y
Log in to vote
0
Answered by 5 years ago
1script.Parent.ClickDetector.MouseClick:connect(function()
2    script.Parent:destroy()
3end

( Parent destroy )

0
fun fact: :destroy() is deprecated LoganboyInCO 150 — 5y

Answer this question