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

I get an error that says it expected a NumberSequence, But got a number does anyone know how to fix?

I'm trying to make a candy wich makes you faster and makes you have a rainbow trail on consumption, But i get an error i do not understand, Can someone help me?

Script:

function Eat()
	script.Parent.Parent.Humanoid.WalkSpeed = 75
	script.Parent.Parent.Head.Trail.Transparency = 0.4
	wait(5)
	script.Parent.Parent.Humanoid.WalkSpeed = 16
	script.Parent.Parent.Head.Trail.Transparency = 1
	wait(0.01)
	script.Parent:Destroy()
end

script.Parent.Activated:connect(Eat)

Error:

Workspace.Nyan Candy.Script:3: bad argument #3 to 'Transparency' (NumberSequence expected, got number)

1 answer

✓ Accepted answer

ParticleEmitters have properties that require specific datatypes. The reasoning behind this correlates with the lifetime of the particle :: by taking in a NumberSequence instead of just a number, the particle can have different transparencies at different parts of its life.

Use the NumberSequence.new constructor

function Eat()
	script.Parent.Parent.Humanoid.WalkSpeed = 75
	script.Parent.Parent.Head.Trail.Transparency = NumberSequence.new(.4)
	wait(5)
	script.Parent.Parent.Humanoid.WalkSpeed = 16
	script.Parent.Parent.Head.Trail.Transparency = NumberSequence.new(1)
	wait(0.01)
	script.Parent:Destroy()
end

script.Parent.Activated:connect(Eat)

1 comment

0

Thanks, It worked! :D

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