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

Why would this script not work? It works with other things.

cd = script.Parent.ClickDetector

cd.MouseClick:connect(function()
	a = game.Workspace:GetChildren(Boat)
		for i,v in pairs(a) do
    		if v.Name == "Part" then 
				for i = 1, 1000 do
					v.CFrame = v.CFrame * CFrame.new(0,.5,-.2)
						wait(.01)
					v.CFrame = v.CFrame * CFrame.new(0,-.5,-.2)
				wait(.01)
    			end
    		end
	end
end)

The script, OnClick, is supposed to make everything in/on the boat move to the left, and slightly move up and down. I've also tried this:

cd.MouseClick:connect(function()
	game.Workspace.Boat:GetChildren()
		for i,v in pairs() do
			for i = 1, 1000 do
				v.CFrame = v.CFrame * CFrame.new(0,0,-.2)
			wait(.01)
    	end
	end
end)

To the moderator note-- I will make sure to do that next time.

1 answer

✓ Accepted answer

Well, looking at the script, everything isn't going to move in unison. In your 2nd for loop, you have two waits in there. That would delay the next part from moving by .02 seconds, and so forth. In other terms, it would basically look like a snake moving. If you want it to move in unison, I recommend creating another for loop with a wait between each for loop so it moves everything together. One other thing I noticed is, in your first for loop, you put Boat. If you're trying to move the boat, you should put game.Workspace.Boat:GetChildren(). I would've put this all as a comment, but it didn't fit. Hope these tips help you.

cd.MouseClick:connect(function()
    game.Workspace.Boat:GetChildren()
        for i,v in pairs() do
            for i = 1, 1000 do
                v.CFrame = v.CFrame * CFrame.new(0,0,-.2)
        end
	-- the wait would go here if you were to add something else. The above is moving everything in unison as you wanted.
    end
end)

5 comments

0

Oooh, thanks.

0

No problem. Test this out. If it does happen to work for you, feel free to bump up my reputation and accept this answer!

0

So, delete the variable 'a' and in your for loop, put what I put in my answer.

0

I edited the second thing on the original post. I decided just to have it move foward, because that would be a lot simpler. Would it look like that?

0

Not exactly, check my updated post.

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