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

How would I work this function?

Asked by 11 years ago

Pixel.Dead.Value.Enabled is the bool value inside the pixel frame, when the function is called and the bool value is enabled, it should do the death animation..

It may be because I am doing this inside the function. Is it? If so what should I do? If not what is wrong?

1while true do
2wait(0.1)
3Pixel.Rotation = Pixel.Rotation + 50
4end

The script

01local Pixel = script.Parent.Pixel
02 
03function die()
04if Pixel.Dead.Value.Enabled == true then
05while true do
06wait(0.1)
07Pixel.Rotation = Pixel.Rotation + 50
08end
09wait(0.5)
10Pixel:TweenPosition(UDim2.new(Pixel.Position.X.Scale,Pixel.Position.X.Offset,Pixel.Position.Y.Scale,Pixel.Position.Y.Offset-500),"Out","Quad",.5)
11Pixel.Rotation = 0  --Reset rotation
12Pixel.Position = {0.5,-284},{0.5,201} --Start position, may need to find another method if we are doing levels.
13Pixel.Dead.Value.Enabled = false    --Reset value
14end
15 
16end

EDIT

01local Pixel = script.Parent.Pixel
02 
03function die()
04if Pixel.Dead.Value.Enabled == true then
05    for i=1,0, +50 do
06        wait(0.1)
07        Pixel.Rotation = Pixel.Rotation = i
08end
09 
10Pixel:TweenPosition(UDim2.new(Pixel.Position.X.Scale,Pixel.Position.X.Offset,Pixel.Position.Y.scale,Pixel.Position.Y.Offset-500),"Out","Quad",.5)
11    pixel.Rotation = 0  --Reset rotation
12 
13Pixel.Position = {0.5,-284},{0.5,201} --Start position, may need to find another method if we are doing levels.
14 
15Pixel.Dead.Value.Enabled = false    --Reset value
16 
17end
18end
19end)

1 answer

Log in to vote
2
Answered by
haillin 60
11 years ago

The Problem is you have a non-terminating while loop. The loop never ends so your script never gets passed it. I'd change it to a For loop to loop for a certain amount of time before moving on to the second part of your script.

0
So I would go to this to learn how to use a for loop? http://wiki.roblox.com/index.php?title=For_loop#For IntellectualBeing 430 — 11y
0
I tried what you said, can you check the edit and see if it looks alright? IntellectualBeing 430 — 11y
Ad

Answer this question