My script won´t run!

I was working on a game and created a script, but it’s not running. I’ve tried many different ways to make it run, but there are no errors and I’m not sure what I’ve done wrong. Here’s the script:

local Status = game.ReplicatedStorage.Values.Status
local inround = game.ReplicatedStorage.Values:WaitForChild("inround")
local SpawnMap = game.Workspace:WaitForChild("spawn")
local Map1 = game.ReplicatedStorage.maps:WaitForChild("map1")
local primarypart = Map1.PrimaryPart

function timer()
	for i = 20, 1, -1 do
		inround.Value = false
		Status.Value = "Starting in: "..i
		wait(1)
	end
end

function ingame()
	local player = game.Players:GetPlayers()
	for i, v in pairs(player) do
		if v.Character ~= nil then
			v.Character.Humanoid.HumanoidRootPart:MoveTo(primarypart.CFrame)
		end
	end
end

function ingametimer()
	for i = 50, 1, -1 do
		inround.Value = true
		Status.Value = "Inround: "..i
		wait(1)
	end
end

for i, v in pairs(game.Players:GetPlayers()) do
	if v.Character ~= nil then
		while true do
			timer()
			wait()
			ingame()
			wait()
			ingametimer()
		end
	end
end

Any feedback would be appreciated. Thank you.

How do you know it’s not running?

I tested the script and didn’t find any errors, but it still won’t run. I’m not sure what the issue is, but I suspect it could be related to the function. Other scripts are working properly, but this one isn’t.

Just put prints in where you think it isn’t working then if they do print it might shows something else is broken

I added a print statement in this line, but it’s not printing anything to the output. I’m not sure why it’s not working.

1 Like

Your issue is with your usage of the for instance. It is playing an infinite version of the loop.
v.Character.Humanoid.HumanoidRootPart should work as just v.Character.HumanoidRootPart

local Status = game.ReplicatedStorage.Values.Status
local inround = game.ReplicatedStorage.Values:WaitForChild("inround")
local SpawnMap = game.Workspace:WaitForChild("spawn")
local Map1 = game.ReplicatedStorage.maps:WaitForChild("map1")
local primarypart = Map1.PrimaryPart

function timer()
    for i = 20, 1, -1 do
        inround.Value = false
        Status.Value = "Starting in: "..i
        wait(1)
    end
end

function ingame()
    local player = game.Players:GetPlayers()
    for i, v in pairs(player) do
        if v.Character ~= nil then
            v.Character.HumanoidRootPart.CFrame = primarypart.CFrame
        end
    end
end

function ingametimer()
    for i = 50, 1, -1 do
        inround.Value = true
        Status.Value = "Inround: "..i
        wait(1)
    end
end

while true do
    timer()
    wait()
    ingame()
    wait()
    ingametimer()
end

1 Like

Maybe try

if v.Character or v.CharacterAdded:Wait() ~= nil then

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.