Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I work this function?

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

✓ Accepted answer

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.

2 comments

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

0

I tried what you said, can you check the edit and see if it looks alright?

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