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

Ball Constraint won't work on moving brick's runservice i need some help please?

Asked by 1 year ago

my moving road won't convey the ragdoll bodies using ball constraint why it won't move together with the road after they fell out of the car??

Ragdoll system

local CollisionsOn = false
local ogparent = script.Parent
script.Parent = game:GetService("ServerScriptService")

game.Players.PlayerAdded:Connect(function(play)
    play.CharacterAdded:Connect(function(char)
        char.Humanoid.BreakJointsOnDeath = false
            char.Humanoid.Died:Connect(function()
                if char:FindFirstChild("HumanoidRootPart") then
                    for _, v in pairs(char:GetDescendants()) do
                        if v:IsA("Motor6D") then
                            local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
                            a0.CFrame = v.C0
                            a1.CFrame = v.C1
                            a0.Parent = v.Part0
                            a1.Parent = v.Part1

                            v.Part0.CanCollide = CollisionsOn
                            v.Part1.CanCollide = CollisionsOn

                            local b = Instance.new("BallSocketConstraint")
                            b.Attachment0 = a0
                            b.Attachment1 = a1
                            b.Parent = v.Part0

                            v:Destroy()
                        end
                    end
                end
            char.HumanoidRootPart.CanCollide = false
        end)
    end)
end)

Moving Brick System

local TweenService = game:GetService("TweenService")
local part = script.Parent
local model = script.Parent.Parent
local cframelocation = script.Parent.Parent.StopLiner.Position

local Info = TweenInfo.new(
 2, -- Length
 Enum.EasingStyle.Linear, -- Easing Style
 Enum.EasingDirection.InOut, -- Easing Direction
 -1, -- Times repeated
 false, -- Reverse
 0 -- Delay
)
local Goals =
{
        CFrame = CFrame.new(cframelocation);
}
local tween = TweenService:Create(part,Info,Goals)
tween:Play()


local service = game:GetService("RunService")

local lastposition = script.Parent.Position

service.Stepped:Connect(function(_, deltatime)
    local currentposition = script.Parent.Position
    local deltaposition = currentposition - lastposition

    local velocity = deltaposition / deltatime

    script.Parent.AssemblyLinearVelocity = velocity

    lastposition = currentposition
end)

why runservice won't move the ragdoll body anyway?

Answer this question