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

How to change multiple beam transparencies at once?

My intention is to change a bunch of beam transparencies at once. So I used this script:

for i = 1, 100 do
	local beam = workspace.Beams
	for _, obj in pairs(beam:GetChildren()) do
		if obj:IsA("Beam") then
			obj.Transparency = obj.Transparency + 0.01
		end
	end
	wait()
end

but nothing happens. All the it does is throw me an error message saying:

"Players.Paradoa.PlayerGui.Menu.TextButton.LocalScript:81: attempt to perform arithmetic (add) on NumberSequence and number"

2 comments

0

It's a number sequence.

0

how do I make the beam fade with a number sequence?

1 answer

✓ Accepted answer

A NumberSequence is a sequence of number keypoints used to determine a value (not the same as animation keypoints, or keyframes as they're referred to). To keep things nice and simple it's usually a good idea to use 3 keypoints for any given NumberSequence. A keypoint for a NumberSequence is created using the NumberSequenceKeypoint constructor:

NumberSequenceKeypoint.new(time, value)

time is the time at which the keypoint is hit, and value is the value of the variable that the keypoint will represent. For transparency purposes, you could go back in your loop and set the keypoint values:

obj.Transparency = NumberSequence.new({
	NumberSequenceKeypoint.new(0, i/100) -- or vice versa
	NumberSequenceKeypoint.new(0.5, i/100) -- or vice versa
	NumberSequenceKeypoint.new(1, i/100) -- or vice versa
})

You can't perform arithmetic on a NumberSequence with just one number; this is because it's a sequence of numbers. A property of a Beam that is similar to Transparency is Color, since that needs a ColorSequence with ColorSequenceKeypoints.

2 comments

0

You forgot a bunch of commas in your code.

0

pffff

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