Not detecting Players BoolValue

Hello!

I am having problems trying to make a elevator game.

Only one player is being given the walkspeed and being teleported back into the elevator.

I am new to scripting.

If anyone can help it would be greatly appreciated!

if newMap == 1 then
		for i,v in pairs(game.Players:GetPlayers()) do
			if v.Playing.Value == true then
				game.Workspace.Music.FastSpeed:Play()
				v.Character.Humanoid.WalkSpeed = 160
				wait(20)
				v.Character.Humanoid.WalkSpeed = 16
				v.Character.HumanoidRootPart.Position = game.Workspace.ElevatorShaft.TeleportPart.Position
				game.Workspace.Music.FastSpeed:Stop()
				tween1Close:Play()
				tween2Close:Play()
				game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
				map:Destroy()
				wait(3)
			end






		end
	end

Make sure you are running it on a server script. Also maybe try putting the Value in a folder? That way you can do

Player.PlayerValues.Playing == true then
blalala

Also maybe try changing :GetPlayers to :GetChildren

It didnt work. Still doesnt teleport the player back into the elevator.

if newMap == 1 then
	for i,v in pairs(game.Players:GetPlayers()) do
		if v.Playing.Value == true then

			game.Workspace.Music.FastSpeed:Play()

			v.Character.Humanoid.WalkSpeed = 160

			task.wait(20)

			v.Character.Humanoid.WalkSpeed = 16
			v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame

			game.Workspace.Music.FastSpeed:Stop()
			
			tween1Close:Play()
			tween2Close:Play()
			
			game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
			
			map:Destroy()
			task.wait(3)
		end
	end
end

Issue was you were moving the Position not the CFrame.

if newMap == 1 then
        game.Workspace.Music.FastSpeed:Play()
		for i,v in pairs(game.Players:GetPlayers()) do
			if v.Playing.Value then
				v.Character.Humanoid.WalkSpeed = 160
				task.delay(20,function()
				    v.Character.Humanoid.WalkSpeed = 16
				    v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
                end)
			end
		end

        task.wait(20)

        game.Workspace.Music.FastSpeed:Stop()
		tween1Close:Play()
		tween2Close:Play()
		game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
		map:Destroy()
		task.wait(3)
	end
end

Yes thank you ill try right now. Problem is it only also puts on walkspeed for one person and not the other.

Example (i know its laggy) Skip to the end of the recording.

robloxapp-20220109-1133353.wmv (3.1 MB)

Full Script:
local mapCount = 3

while true do
	wait(10)
	local TweenService = game:GetService("TweenService")

	local part = game.Workspace.ElevatorShaft.DoorPart1
	local part2 = game.Workspace.ElevatorShaft.DoorPart2
--Closed
	local goal1 = {}
	goal1.Position = Vector3.new(-4.451, 6.5, -206)

	local goal2 = {}
	goal2.Position = Vector3.new(-4.451, 6.5, -200)
-- Open
	local goal3 = {}
	goal3.Position = Vector3.new(-4.451, 6.5, -210)

	local goal4 = {}
	goal4.Position = Vector3.new(-4.451, 6.5, -196)


	local tweenInfo = TweenInfo.new(3)

	local tween1Close = TweenService:Create(part, tweenInfo, goal1)
	local tween2Close = TweenService:Create(part2, tweenInfo, goal2)
	local tween1Open = TweenService:Create(part, tweenInfo, goal3)
	local tween2Open = TweenService:Create(part2, tweenInfo, goal4)
	
	tween1Open:Play()
	tween2Open:Play()
	game.Workspace.ElevatorShaft.BarrierPart.CanCollide = false
	for i,v in  pairs (game.Workspace.Map:GetChildren()) do
		if v then
			v:Destroy()
		end
	end
	for i,v in pairs (game.Workspace.Music:GetChildren()) do
		if v then
			v:Stop()
		end
	end
	local newMap = math.random(1,mapCount)
	local map = game.ReplicatedStorage.Levels[newMap]:Clone()
	map.Parent = workspace.Map
	if newMap == 1 then
		for i,v in pairs(game.Players:GetPlayers()) do
			if v.PlayerStats.Playing.Value == true then

				game.Workspace.Music.FastSpeed:Play()

				v.Character.Humanoid.WalkSpeed = 160

				task.wait(20)

				v.Character.Humanoid.WalkSpeed = 16
				v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame

				game.Workspace.Music.FastSpeed:Stop()

				tween1Close:Play()
				tween2Close:Play()

				game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true

				map:Destroy()
				task.wait(3)
			end
		end
	end
	if newMap == 2 then
		for i,v in pairs(game.Players:GetChildren()) do
			if v.PlayerStats.Playing.Value == true then
				
				game.Workspace.Music.Lasers:Play()

				wait(20)
				v.Character.Humanoid.WalkSpeed = 16
				v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
				game.Workspace.Music.Lasers:Stop()
				tween1Close:Play()
				tween2Close:Play()
				game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
				wait(3)
				map:Destroy()

			end






		end
	end
	
	if newMap == 3 then
		game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
		for i,v in pairs(game.Players:GetChildren()) do
			if v.PlayerStats.Playing.Value == true then

				game.Workspace.Music.High:Play()
				

				wait(10)
				v.Character.Humanoid.WalkSpeed = 16
				v.Character.HumanoidRootPart.CFrame = game.Workspace.ElevatorShaft.TeleportPart.CFrame
				game.Workspace.Music.High:Stop()
				tween1Close:Play()
				tween2Close:Play()
				game.Workspace.ElevatorShaft.BarrierPart.CanCollide = true
				wait(3)
				map:Destroy()
				

			end






		end
	end



end

Does anyone have a fix for this?

Maybe you are creating the “Playing” bool value in just one player. Try to see if it fixes your problem.

R u sure, u r inserting the boolVal to every player.

Yes im sure im inserting it into every player.

game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local PlayerStats = Instance.new("Folder")
	PlayerStats.Name = "PlayerStats"
	PlayerStats.Parent = player
	
	local gold = Instance.new("IntValue")
	gold.Name = "Gold"
	gold.Parent = leaderstats
	local Playing = Instance.new("BoolValue")
	Playing.Name = "Playing"
	Playing.Value = false
	Playing.Parent = PlayerStats

The player bool value is in everyone.

No one can fix it. Ill just leave it for now.

change Position to CFrame. Also if you used a local script to change the boolvalue do not use a server/normal script to detect the boolvalue, it won’t work, so use another local script.