Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

it says attempt to index HumanoidRootPart with nil, help?

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

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

2 comments

0

im gonna test it, waiting for the 1 minute to end

0

Can you please answer as well? thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.