New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
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 2 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 8078 Badge of Merit Moderation Voter Administrator Community Moderator
2 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 7 — 2y
Ad

Answer this question