local function C(C)local e=C:FindFirstChild("\066\101\104\097\118\105\111\117\114\115")if e~=nil then e=e:GetChildren()for s=1,#e,1 do if e[s].Value==true then game.ReplicatedStorage.RemoteEvents.ExecuteBehaviour:FireServer(player.Character,C,e[s].Name)end end end end function characterAdded(e)local s=e:WaitForChild("\072\117\109\097\110\111\105\100")s.WalkSpeed=0 s.Touched:Connect(C)local B=player.PlayerGui:WaitForChild("\083\116\097\114\116\083\099\114\101\101\110")if UserInputService.TouchEnabled==false then if UserInputService.GamepadEnabled then B.StartInstructions.StartLabel.Text="\080\114\101\115\115 \083\112\097\099\101 \111\114 \071\097\109\101\112\097\100 \065 \066\117\116\116\111\110 \116\111 \083\116\097\114\116"else B.StartInstructions.StartLabel.Text="\080\114\101\115\115 \083\112\097\099\101 \116\111 \083\116\097\114\116"end end if reviving==true then reviving=false B:Destroy()s.WalkSpeed=characterWalkSpeed end s.WalkSpeed=0 end player.CharacterAdded:Connect(characterAdded)if player.Character then characterAdded(player.Character)end function checkReviving(C)if C.Name=="\082\101\118\105\118\105\110\103\071\085\073"then reviving=true end end player.PlayerGui.ChildAdded:Connect(checkReviving)if UserInputService.TouchEnabled then UserInputService.ModalEnabled=true UserInputService.TouchStarted:Connect(function(C,e)if e==false then doJump=true end end)UserInputService.TouchEnded:Connect(function()doJump=false end)else ContextActionService:BindAction("\074\117\109\112",function(C,e,s)doJump=e==Enum.UserInputState.Begin end,false,Enum.KeyCode.Space,Enum.KeyCode.ButtonA)end;(game:GetService("\082\117\110\083\101\114\118\105\099\101")).RenderStepped:Connect(function()if player.Character~=nil then if player.Character:FindFirstChild("\072\117\109\097\110\111\105\100")then if doJump==true then jump()end player.Character.Humanoid:Move(Vector3.new(0,0,-1),false)end end end)
-- Handles behaviours
local function characterTouchedBrick(partTouched)
	local behaviours = partTouched:FindFirstChild("Behaviours")
	if behaviours ~= nil then
		behaviours = behaviours:GetChildren()
		for i = 1, #behaviours do
			if behaviours[i].Value == true then
				game.ReplicatedStorage.RemoteEvents.ExecuteBehaviour:FireServer(
					player.Character,
					partTouched,
					behaviours[i].Name
				)
			end
		end
	end
end

function characterAdded(newCharacter)
	local humanoid = newCharacter:WaitForChild("Humanoid")
	humanoid.WalkSpeed = 0
	humanoid.Touched:Connect(characterTouchedBrick)

	local splashScreen = player.PlayerGui:WaitForChild("StartScreen")

	if UserInputService.TouchEnabled == false then
		if UserInputService.GamepadEnabled then
			splashScreen.StartInstructions.StartLabel.Text = "Press Space or Gamepad A Button to Start"
		else
			splashScreen.StartInstructions.StartLabel.Text = "Press Space to Start"
		end
	end
	if reviving == true then
		reviving = false
		splashScreen:Destroy()
		humanoid.WalkSpeed = characterWalkSpeed
	end

	humanoid.WalkSpeed = 0
end
player.CharacterAdded:Connect(characterAdded)

if player.Character then
	characterAdded(player.Character)
end

function checkReviving(addedGui)
	if addedGui.Name == "RevivingGUI" then
		reviving = true
	end
end
player.PlayerGui.ChildAdded:Connect(checkReviving)

if UserInputService.TouchEnabled then
	UserInputService.ModalEnabled = true
	UserInputService.TouchStarted:Connect(function(inputObject, gameProcessedEvent)
		if gameProcessedEvent == false then
			doJump = true
		end
	end)
	UserInputService.TouchEnded:Connect(function()
		doJump = false
	end)
else
	ContextActionService:BindAction("Jump", function(action, userInputState, inputObject)
		doJump = (userInputState == Enum.UserInputState.Begin)
	end, false, Enum.KeyCode.Space, Enum.KeyCode.ButtonA)
end

game:GetService("RunService").RenderStepped:Connect(function()
	if player.Character ~= nil then
		if player.Character:FindFirstChild("Humanoid") then
			if doJump == true then
				jump()
			end
			player.Character.Humanoid:Move(Vector3.new(0, 0, -1), false)
		end
	end
end)
