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 properties in a script from ParticleEmitter?

How to add and change properties in a script from ParticleEmitter? Error starts at

Decal.Size = 0.2

I don't know why this is not working.

local asset = "http://www.roblox.com/asset/?id=395511694"
script.Parent.Upgrade.Touched:connect(function(hit)
	if hit:FindFirstChild("Tix") then
		hit.Tix.Value = hit.Tix.Value * 2
		local Decal = Instance.new("ParticleEmitter",hit)
		Decal.Size = 0.2
		Decal.Lifetime = 0.5
		Decal.EmissionDirection = ("Back")
		Decal.Transparency = 0.5
		Decal.Rate = 10
		Decal.RotSpeed = 50
		Decal.Texture = asset
		Decal.LockedToPart = true
	end
end)

Thanks

2 comments

0

Your answer is confusing I don't really understand what your asking

1

He isn't understanding why the script is erroring on line 6. I understand why, it's because the Size property is a NumberSequence, not a float/number value. What I do not understand is how to use NumberSequences, so if anyone knows, that'd be a great answer for future reference!

2 answers

✓ Accepted answer

As M39a9am3R said, ParticleEmitters' Size property is a NumberSequence; your problem is that you're using a float. Try this, instead:

local asset = "http://www.roblox.com/asset/?id=395511694"
script.Parent.Upgrade.Touched:connect(function(hit)
    if hit:FindFirstChild("Tix") then
        hit.Tix.Value = hit.Tix.Value * 2
        local Decal = Instance.new("ParticleEmitter",hit)
        Decal.Size = NumberSequence.new(.2)
        Decal.Lifetime = 0.5
        Decal.EmissionDirection = ("Back")
        Decal.Transparency = 0.5
        Decal.Rate = 10
        Decal.RotSpeed = 50
        Decal.Texture = asset
        Decal.LockedToPart = true
    end
end)

For more information on NumberSequences, go here. Hope this helped.

local keypoints = {}
table.insert(  keypoints, NumberSequenceKeypoint.new( 0, 0.5, 1 ) )
table.insert(  keypoints, NumberSequenceKeypoint.new( 1, 0, 1 ) )

local sequence = NumberSequence.new( keypoints )

If you were to draw a graph of the sequence, the first argument would be the x axis of graph, 2. argument is y axis and 3. is the max value for the y axis.

That's how i got it at least, I haven't used them myself.

Also, the first argument has to be in range of 0-1, as mentioned in the wiki.

In your case you can use this as well:

local sequence = NumberSequence.new( 0.2 )

Which would make a linear sequence just like you wanted.

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