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

Where did I go wrong?

I'm new to scripting and I'm experimenting with this new thing I learned but it won't work. The script is below. Please fix it and explain what I did wrong. The point of this script is to slowly make the brick transparency until it disappears and then remove it.

function touch
	
	script.Parent.Transparency = 0.2
	
	wait(0.5)
	
	script.Parent.Transparency = 0.5
	
	wait(0.5)
	
	script.Parent.Transparency = 0.7
	
	wait(0.5)
	
	script.Parent.Transparency = 1
	
	wait(0.5)
	
	script.Parent:remove()
	
	end

script.Parent.Touched:connect(touch)

end

Thank-you.

5 comments

0

In the future, please provide your error, although in this situation the problems are pretty obvious.

0

What is my error?

0

All you said is that I made a mistake, not what my mistake is. That comment is useless.

0

He told me in the chat to answer because he was too lazy. .-.

0

How do I talk on the chat? o.o

1 answer

✓ Accepted answer

There are multiple problems here.

First off, touch needs another item behind it. No, not just touch. You need to use touch() or touch(hit).

Second, remove() is depreciated. Use Destroy().

Third, why do the code this way? Much easier to use a for loop instead to save space.

Fourth, no need of the end at the end. end defines the end of some sort of function.

Here's the refinished script.

function touch()

    script.Parent.Transparency = 0.2

for i=1,3 do
script.Parent.Transparency=script.Parent.Transparency+0.3

    wait(0.5)

end
    script.Parent:Destroy()

    end

script.Parent.Touched:connect(touch)






If this helped, make sure to hit the accept button on the right. Cya!

4 comments

0

Um, thanks for the answer but I don't really understand it. I get the "Destory" function but I'm not familiar with this loop thing. Could you write the script without the loop?

0

Oh, I think I get it now.

0

I don't get line 5 and 6. Wouldn't that make the brick's transparency 0.5?

0

No, this would set transparency a bit more (0.3) 3 times.

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