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

How to fix this Loop that is not printing While i have no output error?

local ElevatorPlayers = game.ReplicatedStorage.Players.PlayerValue.Value
local Liftsound = script.Parent.LiftSound
local Hitbox = script.Parent.Hitbox
local tp = workspace.tPoints:FindFirstChild("TpPoint")
Players = 0

-- PlayerValueGiver

local function AddPlayer()
	Hitbox.Touched:Connect(function()
		Players = Players + 1
		hit.Parent:moveTo(teleport.Position)
end)

-- Elevator Main

while true do
	wait()
	if Players >= 1 then 
		print("test")
  end
 end
end


2 comments

0

why do you have 3 ends on the loop? You should only have 2

0

If i remove one it gives me an error

1 answer

Hello, hokyboy!

local ElevatorPlayers = game.ReplicatedStorage.Players.PlayerValue.Value
local Liftsound = script.Parent.LiftSound
local Hitbox = script.Parent.Hitbox
local tp = workspace.tPoints:FindFirstChild("TpPoint")
local Players = 0

-- PlayerValueGiver

local function AddPlayer()
    Hitbox.Touched:Connect(function()
        Players = Players + 1
        hit.Parent:moveTo(teleport.Position)
    end -- This end was at the wrong location...
end)

-- Elevator Main

while true do
    wait()
    if Players >= 1 then 
        print("test")
    end
end


Don't forget that you have to close all functions on your code

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