Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong with this CFrame script?

Asked by 9 years ago

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)()

0
Also note: The contents of the bobby table never changes and removing the transparency line does not change anything crackabottle123 110 — 9y
1
What exactly do you mean is happening? I don't understand. Does it go up and down, but it gets higher each time? BlueTaslem 18071 — 9y
0
Yes, that is what happens crackabottle123 110 — 9y

2 answers

Log in to vote
2
Answered by 9 years ago

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.

Ad
Log in to vote
0
Answered by 9 years ago

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

0
Fixed by moving to a server script crackabottle123 110 — 9y

Answer this question