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

How to make a beam appear after clicking a brick?

Asked by 4 years ago

I'm getting no help so I'm trying again, I have a brick that is supposed to have a beam's transparency turn to 0 after clicking it. This is my current script, and it won't work, I don't have any Idea what I'm doing wrong.

script.Parent.ClickDetector.MouseClick:Connect(function() wait(3) script.Parent.Beam.Transparency = 0 end)

0
Well, this is a messy way to do it, but as far as I can tell, this should work. I would check your hierarchy; did you get the correct location of everything? jakeke12345 1 — 4y
0
Really does look like you might've gotten your hierarchy wrong SteamG00B 1633 — 4y
0
The website didn't load the script correctly, theres an indent between function and wait, and an indent between 0 and end. lnyourarms 55 — 4y
0
The beam is inside a part and the script is also inside the part lnyourarms 55 — 4y
View all comments (4 more)
0
Also, just like programming, the website did what you told it to do. In order to get it to display properly here, you need to put your code in a code block. SteamG00B 1633 — 4y
0
Is the beam a part? SteamG00B 1633 — 4y
0
It's clearly just an actual beam, not a part. He likely simply didn't expect he would need to use a Number Sequence - which to be fair, it is quite stupid you have to for simple transparency values. Maxwell_Edison 105 — 4y
0
It is not "clearly" an actual beam because he never specified what exactly the beam was and both parts and beams have a transparency value. SteamG00B 1633 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

It would help if you looked at, and provided, your errors in the console.

Transparency for beams in roblox is a number sequence, rather than a number. This makes it a bit trickier to modify, as whole numbers (As much as I wish roblox made them...) won't naturally convert over to the proper Number Sequence value.

Instead of turning the transparency to 0, if you are simply trying to turn the beam from invisible to visible, try turning it's Enabled property from False to True instead. This will make it pop on.

script.Parent.Beam.Enabled = true 

If you needed it to be a different transparency at the start, rather than off, you're going to have to look into number sequences.

https://developer.roblox.com/en-us/api-reference/datatype/NumberSequence

I honestly wish, since Beams appear as though they use a basic number, that roblox could naturally convert a number into a simple Number Sequence by itself, but that is sadly not how it works currently.

Hope I could help.

1
Thank you! This finally worked! lnyourarms 55 — 4y
Ad

Answer this question