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

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

Asked by 6 years ago

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

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago

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)
0
Thanks, It worked! :D hextrexs 12 — 6y
Ad

Answer this question