CharacterAdded Won't Work

Hey there so i’m scripting an obby and CharacterAdded won’t seem to work. Here’s the script

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")

local CheckPoints = Workspace.CheckPoints

function PlayerAdded(player)
	print(player, "loaded")
	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = player
	leaderstats.Name = "leaderstats"
	
	local Stage = Instance.new("IntValue")
	Stage.Parent = leaderstats
	Stage.Name = "Stage"
	
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		character:MoveTo(CheckPoints[Stage.Value].Position)
		
		humanoid.Touched:Connect(function(hit)
			if hit.Parent == CheckPoints then 
				if tonumber(hit.Name) == Stage.Value + 1 then 
					Stage.Value = Stage.Value + 1
				end
			end
		end)
	end
end


	
Players.PlayerAdded:Connect(PlayerAdded)

The problem is the player.CharacterAdded line and I’m wondering how I could fix this.

1 Like

Hi, try using the humanoid for MoveTo, not the character itself.

Also, is the problem the character not moving, or the player.CharacterAdded function not running?

Thank you!

2 Likes

You have to put a parenthesee for the CharacterAdded’s “end.”

	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		character:MoveTo(CheckPoints[Stage.Value].Position)
		
		humanoid.Touched:Connect(function(hit)
			if hit.Parent == CheckPoints then 
				if tonumber(hit.Name) == Stage.Value + 1 then 
					Stage.Value = Stage.Value + 1
				end
			end
		end)
	end)-- right here
4 Likes

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