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

Weld breaks when position changed by script?

Asked by 8 years ago

I made my script, the script works, but when it moves the brick, the second brick (which I used a weld plugin to weld with the first brick) doesn't move with it![EDIT2] Changed to CFrame, but now get an "Expected Vector3 got CFrame" Here is my moving script

repeat
wait(2.5)
local victim = workspace:FindFirstChild("Player")
print(victim.Torso.CFrame.X)
wait(0.0001)
    repeat
        wait(0.000001)
        repeat
            wait(0.000001)
            if script.Parent.CFrame.X ~= victim.Torso.CFrame.X then
                if victim.Torso.CFrame.X > script.Parent.CFrame.X then

                    script.Parent.CFrame = CFrame.new(script.Parent.CFrame + Vector3.new(1,0,0))
                elseif victim.Torso.CFrame.X < script.Parent.CFrame.X then

                    script.Parent.CFrame = Vector3.new(script.Parent.CFrame - CFrame.new(1,0,0))
                elseif victim.Torso.CFrame.X == script.Parent.CFrame.X then
                    print("found")
                end
            end
        until script.Parent.Position.X == victim.Torso.Position.X
    until 9 + 10 == 21
until 9 + 10 == 21

Please help!!! Thank you!!!

0
The smallest wait() you can use is renderstepped. HungryJaffer 1246 — 8y

1 answer

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago

If you set the position of a part, it breaks its welds. You can tell if you try to set the position of your own head, because it makes you die.

If you set the CFrame, however, the welded parts will not disjoin, as you can tell if you set the CFrame of your Torso and you teleport.

0
I changed my script, what is wrong? yogipanda123 120 — 8y
0
I don't know what is wrong, why are you asking me what is wrong? 1waffle1 2908 — 8y
0
because you helped me with the first one, im sorry for assuming that you helped me... must have been someone else yogipanda123 120 — 8y
0
Use CFrame.new() and not Vector3.new() when defining a CFrame. 1waffle1 2908 — 8y
Ad

Answer this question