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

What is wrong with this script?

I have a script that is supposed to make a spawn go up and down continuously... But it doesn't work. (This script is a regular script inside of a spawn)

spawn = script.Parent


function UpAndDown()
	for i = 0, 4, 0.1 do
		spawn.CFrame = CFrame.new(0, 0.1, 0)
		wait(0.1)
	end
	
	for i = 0, -4, -0.1 do
		spawn.CFrame = CFrame.new(0, -0.1, 0)
		wait(0.1)
	end

	UpAndDown()
end


UpAndDown()

1 comment

0

I probably did this completely wrong but i'm new to scripting and this is what i thought i was supposed to do...

1 answer

✓ Accepted answer

I changed a few things, but it's pretty simple. It should work now. If you want it to be continuous all you have to do is introduce a loop (while true do).

spawn = script.Parent

function UpAndDown()
    for i = 0, 4, 0.1 do
        spawn.CFrame = spawn.CFrame + Vector3.new(0, 0.1, 0)
        wait(0.1)
    end
    for i = 0, 4, 0.1 do
        spawn.CFrame = spawn.CFrame - Vector3.new(0, 0.1, 0)
        wait(0.1)
    end
end

while true do
	UpAndDown()
	wait(1)
end

1 comment

0

Thanks.

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