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

What is wrong with this CFrame script?

This is mean to CFrame bricks in a table up and down slowly but the bricks eventually creep upwards until they are high in the sky, this happens very slowly.

I have tried changing + Vector3.new() to * CFrame.new but it didn't help :/ bobby is a table containing all the parts

coroutine.wrap(function()
	while true do
		for i = 1,60 do
			for i,v in pairs(bobby) do
				if v.Transparency ~= 1 then
					v.CFrame = v.CFrame + Vector3.new(0, 0.035, 0)
				end	
			end	
			wait(.05)
		end
		for i = 1,60 do
			for i,v in pairs(bobby) do
				if v.Transparency ~= 1 then
					v.CFrame = v.CFrame - Vector3.new(0, 0.035, 0)
				end	
			end	
			wait(0.05)
		end
	end
end)()

3 comments

0

Also note: The contents of the bobby table never changes and removing the transparency line does not change anything

1

What exactly do you mean is happening? I don't understand. Does it go up and down, but it gets higher each time?

0

Yes, that is what happens

2 answers

I had some problems with CFrame when I first started but since then I've become a lot more adept in it. The problem in your script is that you are adding or subtracting CFrame/Vector3 values. What you should be doing is multiplying by CFrame values.

Like this.

coroutine.wrap(function()
    while true do
        for i = 1,60 do
            for i,v in pairs(bobby) do
                if v.Transparency ~= 1 then
                    v.CFrame = v.CFrame * CFrame.new(0, 0, 0) --You'll have to mess with the values to get it right.
                end 
            end 
            wait(.05)
        end
        for i = 1,60 do
            for i,v in pairs(bobby) do
                if v.Transparency ~= 1 then
                    v.CFrame = v.CFrame * CFrame.new(0, 0, 0)
                end 
            end 
            wait(0.05)
        end
    end
end)()

Also be aware that negative values take the opposite direction of positive values.

Found the issue, I really should have figured this out myself I didn't give you guys enough information, sorry.

The CFraming occurs in a local script and when the player dies the script of course restarts by going higher. Every time the players death occurs the parts start moving upwards.

Again, I apologize for not providing enough info. I will upvote all who assisted me

1 comment

0

Fixed by moving to a server script

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