StarterPlayerScripts working in studio but not on roblox

I am working on an experience for the Roblox Developer Challenge 2024 and I prepared everything to submit my experience but when I tested it on Roblox I found that the game is unplayable. (camera in ground and cant move character)
Everything works fine in studio and there are no error messages.
I tried putting my scripts in StarterCharacterScripts but that just breaks it for studio and Roblox.

Here are my scripts. They are both localscripts


	local player = game.Players.LocalPlayer
	local camera = workspace.CurrentCamera

	player.CharacterAdded:Wait()

	player.Character:WaitForChild("HumanoidRootPart")

	camera.CameraSubject = player.Character.HumanoidRootPart
	camera.CameraType = Enum.CameraType.Attach
	camera.FieldOfView = 40

	local RunService = game:GetService("RunService")

	local function onUpdate()
		if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
			camera.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position) * CFrame.new(0,4,80)
		end
	end

	RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onUpdate)




local player = game.Players.LocalPlayer
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")



local function movement()

	local rootpart = player.Character:WaitForChild("HumanoidRootPart")
	local linearvelocity = rootpart:WaitForChild("Attachment").LinearVelocity

	

	local ContentProvider = game:GetService("ContentProvider")

	local assets = { "rbxassetid://16130966701" --jump
		,"rbxassetid://16130984393" --fall
		,"rbxassetid://16130957362" --dive
		,"rbxassetid://16130989335" --dive land
		,"rbxassetid://16130994122" --walk
		,"rbxassetid://16130999782" --wall slide back
		,"rbxassetid://16131003798" --wall slide front
		,"rbxassetid://16131097807" --wall jump
		,"rbxassetid://16131158795" --ledge climb
		,"rbxassetid://16131962964"	--pain6
		,"rbxassetid://16131956731"
		,"rbxassetid://16131952691"
		,"rbxassetid://16131946961"
		,"rbxassetid://16131942168"
		,"rbxassetid://16131934512"	--pain1
		,"rbxassetid://16144669450" --run
		,"rbxassetid://16149487417" --run2
		,"rbxassetid://16144666117" --land
		,"rbxassetid://16144657672" --idle
		,"rbxassetid://16146905636"	--grass music
		,"rbxassetid://16146921732" --lava music
		,"rbxassetid://16147333654" --doublejump flip
		,"rbxassetid://16149011068" --block bonk
		,"rbxassetid://16149016757" -- coin collect
		,"rbxassetid://16149002243" --jump sound normal
		,"rbxassetid://16149004910" --jump sound double
		,"rbxassetid://16149007590" --jump sound dive
		,"rbxassetid://16149870454" --devious face
	}
	ContentProvider:PreloadAsync(assets)
	print("All assets loaded.")


	local humanoid = player.Character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")

	local Animation = Instance.new("Animation")
	Animation.AnimationId = "rbxassetid://16130966701"
	AnimationTrack = animator:LoadAnimation(Animation)
	
	isidle = false
	runanim = false
	
	Animation = Instance.new("Animation")
	Animation.AnimationId = ("rbxassetid://0")
	
	local function animate(id)

		if id ~= Animation.AnimationId then
			AnimationTrack:Stop()
			Animation = Instance.new("Animation")
			Animation.AnimationId = ("rbxassetid://"..id)
			AnimationTrack = animator:LoadAnimation(Animation)
			AnimationTrack:Play()
		end
	end

	local function playsound1(id)
		player.Character.HumanoidRootPart:FindFirstChild(id):Play()
	end
	
	
	
	debuggui = player.PlayerGui.DebugGui
	
	

	collisionstuff = player.Character:WaitForChild("CollisionStuff")

	local jumping = false
	local leftValue, rightValue = 0, 0

	local facingdirection = 1	--  -1=left 1=right
	local ySpeed = 0

	local onfloor = true
	local actionstate = 1		--   1=stand/walk  2=dash
	isjump = false
	extravelocity = 0
	istouchingwall = false
	moveDirection = 0
	actualfacedirection = 1
	backwall = 1
	cyotetime = 10
	floortime = 10
	jumpsleft = 1
	airjump = false

	flip = false


	local function onLeft(actionName, inputState)
		if inputState == Enum.UserInputState.Begin then	
			facingdirection = -1
			leftValue = 1
		elseif inputState == Enum.UserInputState.End then
			leftValue = 0
		end
	end

	local function onRight(actionName, inputState)
		if inputState == Enum.UserInputState.Begin then
			facingdirection = 1
			rightValue = 1
		elseif inputState == Enum.UserInputState.End then
			rightValue = 0
		end
	end

	local function onJump(actionName, inputState)
		if inputState == Enum.UserInputState.Begin then
			isjump = true

			if (istouchingwall == true or backwall == 2) and onfloor == false then
				if backwall ~= 2 then
					extravelocity = actualfacedirection*-65
					flip = true
					facingdirection = facingdirection*-1
				else
					extravelocity = actualfacedirection*65
				end
				backwall = 1
				playsound1("JumpSound1")
				animate(16131097807)

				if ySpeed <= 50  then
					ySpeed = 65
				end
				
			elseif cyotetime <0 and jumpsleft >=.1 then
				jumpsleft = jumpsleft-1
				extravelocity = 0
				if ySpeed <= 65 then
					ySpeed = 65
					playsound1("JumpSound2")
					animate(16147333654)
					flip = true
					if actionstate == 2 then
						actionstate = 3
					end
				end
				--]]
			end
		elseif inputState == Enum.UserInputState.End then
			isjump = false
		end
	end

	local function onDash(actionName, inputState)
		if inputState == Enum.UserInputState.Begin then
			if actionstate == 1 then
				--isjump = true
				if leftValue ~= rightValue then
					if leftValue == 1 then
						facingdirection = -1
					elseif rightValue == 1 then
						facingdirection = 1
					end
				end
				if extravelocity <= 90 and extravelocity >= -90 then
					actionstate = 2
					extravelocity = facingdirection*90
				end
				if ySpeed <= 40 then
					ySpeed = 50
				end
				flip = true
				playsound1("JumpSound3")
				animate(16130957362)
			end

		elseif inputState == Enum.UserInputState.End then
			--isjump = false


		end
	end








	local function onUpdate()
		if player.Character.Humanoid.Health >=0 then
			local collisionstuff = player.Character:WaitForChild("CollisionStuff")
			if player.Character and player.Character:FindFirstChild("Humanoid") then
				if jumping then
					player.Character.Humanoid.Jump = true
				end
				moveDirection = rightValue - leftValue
				if actionstate == 2 then
					moveDirection = moveDirection*10
				else--if onfloor == true then
					moveDirection = moveDirection*50
				--else
				--	moveDirection = moveDirection*35
				end
				
				
				if extravelocity >=5 and extravelocity<=-5 then
					extravelocity = extravelocity+((rightValue-leftValue)*5)
					if extravelocity <=5 and extravelocity>=-5 then
						extravelocity = 0
					end
				end
				
				
				

				if floortime >= 3 or flip == true then
					flip = false
					if facingdirection >= 0 then		--set z to 0
						actualfacedirection = 1
						rootpart.CFrame = (CFrame.new(rootpart.Position.X, rootpart.Position.Y, 0) * CFrame.Angles(0,80,0))
					elseif facingdirection <= 0 then
						actualfacedirection = -1
						rootpart.CFrame = (CFrame.new(rootpart.Position.X, rootpart.Position.Y, 0) * CFrame.Angles(0,-80,0))
					end
				end
				if floortime >= 15 and actionstate == 3 then
					actionstate = 1
				end

				backwall = 0
				istouchingwall =false
				local touching = game.Workspace:GetPartsInPart(collisionstuff.WallCollide)
				for i, v in pairs(touching) do
					if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
						if v.CanCollide == true then
							animate(16131003798)
							istouchingwall = true
							backwall = 1
							if (actualfacedirection==1 and extravelocity>=0)or(actualfacedirection==-1 and extravelocity<=0) then
								extravelocity=0
							end
						end
					end
				end
				if (istouchingwall == true or backwall == 2) and ySpeed <= 1 then
					ySpeed = ySpeed-1
				else
					ySpeed = ySpeed-5
				end
				local touching = game.Workspace:GetPartsInPart(collisionstuff.WallCollideBack)
				for i, v in pairs(touching) do
					if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
						--print(v)
						if v.CanCollide == true then
							if not((actualfacedirection==1 and extravelocity>=-5) or (actualfacedirection==-1 and extravelocity<=5)) then
								animate(16130999782)
							end
							--print("back2back")
							
							backwall = 2
							
							if (actualfacedirection==-1 and extravelocity>=0)or(actualfacedirection==1 and extravelocity<=0) then
								extravelocity=0
							end
						end
					end
				end

				if istouchingwall == true or backwall == 3 then
					local edgeclimb = true
					local touching = game.Workspace:GetPartsInPart(collisionstuff.ClimbCollide)
					for i, v in pairs(touching) do
						if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
							if v.CanCollide == true then
								edgeclimb = false
							end
						end
					end
					if edgeclimb == true then
						animate(16131158795)
						ySpeed = 70
					end
				end



				if extravelocity >= 2 or extravelocity <= -2 then
					if cyotetime >=5 then
						extravelocity = extravelocity*.95
					end
				else
					extravelocity = 0
				end


				onfloor = false
				floortime = floortime-1
				if ySpeed <= 0 then
					local touching = game.Workspace:GetPartsInPart(collisionstuff.FloorCollide)
					for i, v in pairs(touching) do
						--print(v.Name)
						if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
							if v.CanCollide == true then
								--print("floor is "..v.Name)
								ySpeed = 0
								onfloor = true
								cyotetime = 10
								floortime = floortime+2
								extravelocity = extravelocity*.95
								backwall = 1
								jumpsleft = 1
								if actionstate == 2 then
									animate(16130989335)
									actionstate = 3
								end
							end
						end
					end
				end
				
				if onfloor == false and cyotetime <= 8 then
					floortime = 0
				end

				if ySpeed >= 0 then
					local touching = game.Workspace:GetPartsInPart(collisionstuff.RoofCollide)
					for i, v in pairs(touching) do
						if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
							if v.CanCollide == true then
								
								ySpeed = math.round(ySpeed*-.5)
							end
						end
					end
				end

				if isjump == true and cyotetime >= 0 then
					playsound1("JumpSound1")
					animate(16130966701)
					if extravelocity ~= 0 then
						extravelocity = extravelocity*.4
					end
					ySpeed = 80
					actionstate = 1
					cyotetime = 0
				end



				cyotetime = cyotetime-1


				local xSpeed = moveDirection+extravelocity
				if xSpeed >= 80 then
					xSpeed = 80
				end
				if xSpeed <= -80 then
					xSpeed = -80
				end

				--player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
				--linearvelocity.VectorVelocity = Vector3.new(moveDirection,0,0)
				--print(xSpeed..", "..ySpeed..", 0")
				debuggui.Speedometer.Text = (xSpeed..", "..ySpeed..", 0")
				debuggui.jumps.Text = jumpsleft
				if jumpsleft >= .1 then
					debuggui.jumps.BackgroundColor = BrickColor.new(0,255,0)
				else
					debuggui.jumps.BackgroundColor = BrickColor.new(255,0,0)
				end
				
				
				if isidle == false and math.round(xSpeed)==0 and ySpeed <= 5 and ySpeed >= -5 and cyotetime >=0 and actionstate <=2 then
					debuggui.idle.BackgroundColor = BrickColor.new(0,255,0)
					isidle = true
					runanim = false
					animate(16144657672)
				else
					debuggui.idle.BackgroundColor = BrickColor.new(255,0,0)
				end
				if runanim == false and (math.round(xSpeed)>=5 or math.round(xSpeed)<=-5) and ySpeed <= 5 and ySpeed >= -5 and cyotetime >=0 and actionstate <=2 then
					debuggui.runn.BackgroundColor = BrickColor.new(0,255,0)
					runanim = true
					isidle = false
					animate(16149487417)
				else
					debuggui.runn.BackgroundColor = BrickColor.new(255,0,0)
				end
				
				
				
				
				local velocity = Vector3.new(xSpeed,ySpeed,0)
				rootpart.Velocity = velocity
			end
		end
	end

	RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)

	ContextActionService:BindAction("Left", onLeft, true, "a", Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
	ContextActionService:BindAction("Right", onRight, true, "d", Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
	ContextActionService:BindAction("Jump", onJump, true, "w", Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)

	ContextActionService:BindAction("Dash", onDash, true, Enum.KeyCode.LeftShift)

end




player.CharacterAdded:Connect(function(character)
	
	movement()

	character.Humanoid.Died:Connect(function()
		print(player.Name.." died")
	end)
end)

There is no chance that I will get this fixed before the Developer Challenge deadline. I don’t know why I even bothered trying to participate. This code sucks anyways.

For the bottom script, the character could have already loaded in before your connection happens, so none of the code would have ran unless you reset.

Code:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")



local function movement()

	local rootpart = player.Character:WaitForChild("HumanoidRootPart")
	local linearvelocity = rootpart:WaitForChild("Attachment").LinearVelocity



	local ContentProvider = game:GetService("ContentProvider")

	local assets = { "rbxassetid://16130966701" --jump
		,"rbxassetid://16130984393" --fall
		,"rbxassetid://16130957362" --dive
		,"rbxassetid://16130989335" --dive land
		,"rbxassetid://16130994122" --walk
		,"rbxassetid://16130999782" --wall slide back
		,"rbxassetid://16131003798" --wall slide front
		,"rbxassetid://16131097807" --wall jump
		,"rbxassetid://16131158795" --ledge climb
		,"rbxassetid://16131962964"	--pain6
		,"rbxassetid://16131956731"
		,"rbxassetid://16131952691"
		,"rbxassetid://16131946961"
		,"rbxassetid://16131942168"
		,"rbxassetid://16131934512"	--pain1
		,"rbxassetid://16144669450" --run
		,"rbxassetid://16149487417" --run2
		,"rbxassetid://16144666117" --land
		,"rbxassetid://16144657672" --idle
		,"rbxassetid://16146905636"	--grass music
		,"rbxassetid://16146921732" --lava music
		,"rbxassetid://16147333654" --doublejump flip
		,"rbxassetid://16149011068" --block bonk
		,"rbxassetid://16149016757" -- coin collect
		,"rbxassetid://16149002243" --jump sound normal
		,"rbxassetid://16149004910" --jump sound double
		,"rbxassetid://16149007590" --jump sound dive
		,"rbxassetid://16149870454" --devious face
	}
	ContentProvider:PreloadAsync(assets)
	print("All assets loaded.")


	local humanoid = player.Character:WaitForChild("Humanoid")
	local animator = humanoid:WaitForChild("Animator")

	local Animation = Instance.new("Animation")
	Animation.AnimationId = "rbxassetid://16130966701"
	AnimationTrack = animator:LoadAnimation(Animation)

	isidle = false
	runanim = false

	Animation = Instance.new("Animation")
	Animation.AnimationId = ("rbxassetid://0")

	local function animate(id)

		if id ~= Animation.AnimationId then
			AnimationTrack:Stop()
			Animation = Instance.new("Animation")
			Animation.AnimationId = ("rbxassetid://"..id)
			AnimationTrack = animator:LoadAnimation(Animation)
			AnimationTrack:Play()
		end
	end

	local function playsound1(id)
		player.Character.HumanoidRootPart:FindFirstChild(id):Play()
	end



	debuggui = player.PlayerGui.DebugGui



	collisionstuff = player.Character:WaitForChild("CollisionStuff")

	local jumping = false
	local leftValue, rightValue = 0, 0

	local facingdirection = 1	--  -1=left 1=right
	local ySpeed = 0

	local onfloor = true
	local actionstate = 1		--   1=stand/walk  2=dash
	isjump = false
	extravelocity = 0
	istouchingwall = false
	moveDirection = 0
	actualfacedirection = 1
	backwall = 1
	cyotetime = 10
	floortime = 10
	jumpsleft = 1
	airjump = false

	flip = false


	local function onLeft(actionName, inputState)
		if inputState == Enum.UserInputState.Begin then	
			facingdirection = -1
			leftValue = 1
		elseif inputState == Enum.UserInputState.End then
			leftValue = 0
		end
	end

	local function onRight(actionName, inputState)
		if inputState == Enum.UserInputState.Begin then
			facingdirection = 1
			rightValue = 1
		elseif inputState == Enum.UserInputState.End then
			rightValue = 0
		end
	end

	local function onJump(actionName, inputState)
		if inputState == Enum.UserInputState.Begin then
			isjump = true

			if (istouchingwall == true or backwall == 2) and onfloor == false then
				if backwall ~= 2 then
					extravelocity = actualfacedirection*-65
					flip = true
					facingdirection = facingdirection*-1
				else
					extravelocity = actualfacedirection*65
				end
				backwall = 1
				playsound1("JumpSound1")
				animate(16131097807)

				if ySpeed <= 50  then
					ySpeed = 65
				end

			elseif cyotetime <0 and jumpsleft >=.1 then
				jumpsleft = jumpsleft-1
				extravelocity = 0
				if ySpeed <= 65 then
					ySpeed = 65
					playsound1("JumpSound2")
					animate(16147333654)
					flip = true
					if actionstate == 2 then
						actionstate = 3
					end
				end
				--]]
			end
		elseif inputState == Enum.UserInputState.End then
			isjump = false
		end
	end

	local function onDash(actionName, inputState)
		if inputState == Enum.UserInputState.Begin then
			if actionstate == 1 then
				--isjump = true
				if leftValue ~= rightValue then
					if leftValue == 1 then
						facingdirection = -1
					elseif rightValue == 1 then
						facingdirection = 1
					end
				end
				if extravelocity <= 90 and extravelocity >= -90 then
					actionstate = 2
					extravelocity = facingdirection*90
				end
				if ySpeed <= 40 then
					ySpeed = 50
				end
				flip = true
				playsound1("JumpSound3")
				animate(16130957362)
			end

		elseif inputState == Enum.UserInputState.End then
			--isjump = false


		end
	end








	local function onUpdate()
		if player.Character.Humanoid.Health >=0 then
			local collisionstuff = player.Character:WaitForChild("CollisionStuff")
			if player.Character and player.Character:FindFirstChild("Humanoid") then
				if jumping then
					player.Character.Humanoid.Jump = true
				end
				moveDirection = rightValue - leftValue
				if actionstate == 2 then
					moveDirection = moveDirection*10
				else--if onfloor == true then
					moveDirection = moveDirection*50
					--else
					--	moveDirection = moveDirection*35
				end


				if extravelocity >=5 and extravelocity<=-5 then
					extravelocity = extravelocity+((rightValue-leftValue)*5)
					if extravelocity <=5 and extravelocity>=-5 then
						extravelocity = 0
					end
				end




				if floortime >= 3 or flip == true then
					flip = false
					if facingdirection >= 0 then		--set z to 0
						actualfacedirection = 1
						rootpart.CFrame = (CFrame.new(rootpart.Position.X, rootpart.Position.Y, 0) * CFrame.Angles(0,80,0))
					elseif facingdirection <= 0 then
						actualfacedirection = -1
						rootpart.CFrame = (CFrame.new(rootpart.Position.X, rootpart.Position.Y, 0) * CFrame.Angles(0,-80,0))
					end
				end
				if floortime >= 15 and actionstate == 3 then
					actionstate = 1
				end

				backwall = 0
				istouchingwall =false
				local touching = game.Workspace:GetPartsInPart(collisionstuff.WallCollide)
				for i, v in pairs(touching) do
					if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
						if v.CanCollide == true then
							animate(16131003798)
							istouchingwall = true
							backwall = 1
							if (actualfacedirection==1 and extravelocity>=0)or(actualfacedirection==-1 and extravelocity<=0) then
								extravelocity=0
							end
						end
					end
				end
				if (istouchingwall == true or backwall == 2) and ySpeed <= 1 then
					ySpeed = ySpeed-1
				else
					ySpeed = ySpeed-5
				end
				local touching = game.Workspace:GetPartsInPart(collisionstuff.WallCollideBack)
				for i, v in pairs(touching) do
					if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
						--print(v)
						if v.CanCollide == true then
							if not((actualfacedirection==1 and extravelocity>=-5) or (actualfacedirection==-1 and extravelocity<=5)) then
								animate(16130999782)
							end
							--print("back2back")

							backwall = 2

							if (actualfacedirection==-1 and extravelocity>=0)or(actualfacedirection==1 and extravelocity<=0) then
								extravelocity=0
							end
						end
					end
				end

				if istouchingwall == true or backwall == 3 then
					local edgeclimb = true
					local touching = game.Workspace:GetPartsInPart(collisionstuff.ClimbCollide)
					for i, v in pairs(touching) do
						if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
							if v.CanCollide == true then
								edgeclimb = false
							end
						end
					end
					if edgeclimb == true then
						animate(16131158795)
						ySpeed = 70
					end
				end



				if extravelocity >= 2 or extravelocity <= -2 then
					if cyotetime >=5 then
						extravelocity = extravelocity*.95
					end
				else
					extravelocity = 0
				end


				onfloor = false
				floortime = floortime-1
				if ySpeed <= 0 then
					local touching = game.Workspace:GetPartsInPart(collisionstuff.FloorCollide)
					for i, v in pairs(touching) do
						--print(v.Name)
						if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
							if v.CanCollide == true then
								--print("floor is "..v.Name)
								ySpeed = 0
								onfloor = true
								cyotetime = 10
								floortime = floortime+2
								extravelocity = extravelocity*.95
								backwall = 1
								jumpsleft = 1
								if actionstate == 2 then
									animate(16130989335)
									actionstate = 3
								end
							end
						end
					end
				end

				if onfloor == false and cyotetime <= 8 then
					floortime = 0
				end

				if ySpeed >= 0 then
					local touching = game.Workspace:GetPartsInPart(collisionstuff.RoofCollide)
					for i, v in pairs(touching) do
						if v.ClassName == "Part" and v.Parent ~= player.Character and v.Parent ~= collisionstuff then
							if v.CanCollide == true then

								ySpeed = math.round(ySpeed*-.5)
							end
						end
					end
				end

				if isjump == true and cyotetime >= 0 then
					playsound1("JumpSound1")
					animate(16130966701)
					if extravelocity ~= 0 then
						extravelocity = extravelocity*.4
					end
					ySpeed = 80
					actionstate = 1
					cyotetime = 0
				end



				cyotetime = cyotetime-1


				local xSpeed = moveDirection+extravelocity
				if xSpeed >= 80 then
					xSpeed = 80
				end
				if xSpeed <= -80 then
					xSpeed = -80
				end

				--player.Character.Humanoid:Move(Vector3.new(moveDirection,0,0), false)
				--linearvelocity.VectorVelocity = Vector3.new(moveDirection,0,0)
				--print(xSpeed..", "..ySpeed..", 0")
				debuggui.Speedometer.Text = (xSpeed..", "..ySpeed..", 0")
				debuggui.jumps.Text = jumpsleft
				if jumpsleft >= .1 then
					debuggui.jumps.BackgroundColor = BrickColor.new(0,255,0)
				else
					debuggui.jumps.BackgroundColor = BrickColor.new(255,0,0)
				end


				if isidle == false and math.round(xSpeed)==0 and ySpeed <= 5 and ySpeed >= -5 and cyotetime >=0 and actionstate <=2 then
					debuggui.idle.BackgroundColor = BrickColor.new(0,255,0)
					isidle = true
					runanim = false
					animate(16144657672)
				else
					debuggui.idle.BackgroundColor = BrickColor.new(255,0,0)
				end
				if runanim == false and (math.round(xSpeed)>=5 or math.round(xSpeed)<=-5) and ySpeed <= 5 and ySpeed >= -5 and cyotetime >=0 and actionstate <=2 then
					debuggui.runn.BackgroundColor = BrickColor.new(0,255,0)
					runanim = true
					isidle = false
					animate(16149487417)
				else
					debuggui.runn.BackgroundColor = BrickColor.new(255,0,0)
				end




				local velocity = Vector3.new(xSpeed,ySpeed,0)
				rootpart.Velocity = velocity
			end
		end
	end

	RunService:BindToRenderStep("Control", Enum.RenderPriority.Input.Value, onUpdate)

	ContextActionService:BindAction("Left", onLeft, true, "a", Enum.KeyCode.Left, Enum.KeyCode.DPadLeft)
	ContextActionService:BindAction("Right", onRight, true, "d", Enum.KeyCode.Right, Enum.KeyCode.DPadRight)
	ContextActionService:BindAction("Jump", onJump, true, "w", Enum.KeyCode.Space, Enum.KeyCode.Up, Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)

	ContextActionService:BindAction("Dash", onDash, true, Enum.KeyCode.LeftShift)

end

local function onCharacterAdded(character)
	movement()

	character.Humanoid.Died:Connect(function()
		print(player.Name.." died")
	end)
end

player.CharacterAdded:Connect(onCharacterAdded)
onCharacterAdded(char)

This fixed the movement! Thank you so much! Now I just have to fix the camera and everything should be working!

No problem. If everything works, you can set mine as the solution.

If you have any other questions, feel free to ask.