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

it says attempt to index HumanoidRootPart with nil, help?

Asked by 3 years ago
local InterEnab = game.ReplicatedStorage.IntermissionEnabled
local Time = script.Parent.Value.Value

if InterEnab.Value == true then
    script.Parent.Parent.Enabled = true

    while Time ~= 0 do
        Time = Time -1
        script.Parent.Text = Time
        wait(1)
    end
    if Time == 0 then
        local Players = game.Players:GetPlayers()

        local Maps = game.ReplicatedStorage.Maps:GetChildren()
        local ChosenMap = Maps[math.random(1,#Maps)]

        local Parts = ChosenMap:GetChildren()
        Parts.Position = Vector3.new(-306.5, 500.662, -76)
        ChosenMap:Clone().Parent = game.Workspace

        game.Workspace.Lobby:Clone().Parent = game.ReplicatedStorage
        game.Workspace.Lobby:Destroy()

        Players.Character.HumanoidRootPart.Position = Vector3.new(-306.5, 546.662, -76)
    end 
end

1 answer

Log in to vote
0
Answered by 3 years ago

Replace your script with the one below:

local InterEnab = game.ReplicatedStorage.IntermissionEnabled
local Time = script.Parent.Value.Value

if InterEnab.Value == true then
    script.Parent.Parent.Enabled = true

    while Time ~= 0 do
        Time = Time -1
        script.Parent.Text = Time
        wait(1)
    end
    if Time == 0 then
        local Players = game.Players:GetPlayers()

        local Maps = game.ReplicatedStorage.Maps:GetChildren()
        local ChosenMap = Maps[math.random(1,#Maps)]

        local Parts = ChosenMap:GetChildren()
        Parts.Position = Vector3.new(-306.5, 500.662, -76)
        ChosenMap:Clone().Parent = game.Workspace

        game.Workspace.Lobby:Clone().Parent = game.ReplicatedStorage
        game.Workspace.Lobby:Destroy()

        for _, plr in pairs(Players) do --loops through all player instances
            plr.Character.HumanoidRootPart.Position = Vector3.new(-306.5, 546.662, -76)
            --Repositions each player's HumanoidRootPart individually
        end

    end 
end
0
im gonna test it, waiting for the 1 minute to end sonichfan 62 — 3y
0
Can you please answer as well? thanks. Roblox28721 10 — 3y
Ad

Answer this question