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

Where did I go wrong?

Asked by 8 years ago

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.

0
In the future, please provide your error, although in this situation the problems are pretty obvious. Perci1 4988 — 8y
0
What is my error? TetsuyaMitsuru 10 — 8y
0
All you said is that I made a mistake, not what my mistake is. That comment is useless. TetsuyaMitsuru 10 — 8y
0
He told me in the chat to answer because he was too lazy. .-. ChemicalHex 979 — 8y
0
How do I talk on the chat? o.o TetsuyaMitsuru 10 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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!

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? TetsuyaMitsuru 10 — 8y
0
Oh, I think I get it now. TetsuyaMitsuru 10 — 8y
0
I don't get line 5 and 6. Wouldn't that make the brick's transparency 0.5? TetsuyaMitsuru 10 — 8y
0
No, this would set transparency a bit more (0.3) 3 times. ChemicalHex 979 — 8y
Ad

Answer this question