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

Why does line 31 of my script think the value of hrp's velocity is not a vector3? [Solved]

Asked by 4 years ago
Edited by DeceptiveCaster 4 years ago

This question has been solved by the original poster.

My script i wrote to stop time does not like line 31. Apparently the value that got stored for is a nil and not a vector3 so when line 31 tries to use it to give humanoidrootparts back their velocity it just gives back a nil value. the script is written as follows.

game.ReplicatedStorage.StopTime.OnServerEvent:Connect(function()
    game.Lighting.timestoplight.Enabled = true
    local tablo = game.Workspace:GetDescendants()
    for i,v in next, tablo do
        local function thread()
            if v.Name == "Part" then
                ank = v.Anchored
                vel = v.Velocity
                v.Anchored = true
                v.Velocity = Vector3.new(0,0,0)
            end
        end
        local function thread2()
            if v.Name == "HumanoidRootPart" then
                ank2 = v.Anchored
                vel2 = v.Velocity
                v.Anchored = true
                v.Velocity = Vector3.new(0,0,0)
            end
        end
        spawn(thread)
    end
end)
game.ReplicatedStorage.EndStopTime.OnServerEvent:Connect(function()
    game.Lighting.timestoplight.Enabled = false
    local tablo = game.Workspace:GetDescendants()
    for i,v in next, tablo do
        local function thread2()
            if v.Name == "HumanoidRootPart" then
                v.Anchored = ank2
                v.Velocity = vel2
            end
        end
        local function thread()
            if v.Name == "Part" then
                v.Anchored = ank
                v.Velocity = vel
            end
        end
        spawn(thread)
        spawn(thread2)
    end
end)

1 answer

Log in to vote
0
Answered by 4 years ago

it appears i forgot to thread the second thread in the function for when timestop begins

Ad

Answer this question