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 10 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?

while true do
wait(0.1)
Pixel.Rotation = Pixel.Rotation + 50
end

The script


local Pixel = script.Parent.Pixel function die() if Pixel.Dead.Value.Enabled == true then while true do wait(0.1) Pixel.Rotation = Pixel.Rotation + 50 end wait(0.5) Pixel:TweenPosition(UDim2.new(Pixel.Position.X.Scale,Pixel.Position.X.Offset,Pixel.Position.Y.Scale,Pixel.Position.Y.Offset-500),"Out","Quad",.5) Pixel.Rotation = 0 --Reset rotation Pixel.Position = {0.5,-284},{0.5,201} --Start position, may need to find another method if we are doing levels. Pixel.Dead.Value.Enabled = false --Reset value end end

EDIT

local Pixel = script.Parent.Pixel

function die()
if Pixel.Dead.Value.Enabled == true then
    for i=1,0, +50 do
        wait(0.1)
        Pixel.Rotation = Pixel.Rotation = i
end

Pixel:TweenPosition(UDim2.new(Pixel.Position.X.Scale,Pixel.Position.X.Offset,Pixel.Position.Y.scale,Pixel.Position.Y.Offset-500),"Out","Quad",.5)
    pixel.Rotation = 0  --Reset rotation

Pixel.Position = {0.5,-284},{0.5,201} --Start position, may need to find another method if we are doing levels.

Pixel.Dead.Value.Enabled = false    --Reset value

end
end
end)

1 answer

Log in to vote
2
Answered by
haillin 60
10 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 — 10y
0
I tried what you said, can you check the edit and see if it looks alright? IntellectualBeing 430 — 10y
Ad

Answer this question