local function h(h)local c=h:FindFirstChild("\066\101\104\097\118\105\111\117\114\115")if c~=nil then c=c:GetChildren()for j=1,#c,1 do if c[j].Value==true then game.ReplicatedStorage.RemoteEvents.ExecuteBehaviour:FireServer(player.Character,h,c[j].Name)if string.find(c[j].Name,"\075\105\108\108")then SmoothDie()end end end end end function characterAdded(c)ResetGame()bindFuc:Invoke(true)character=player.Character humanoid=character:WaitForChild("\072\117\109\097\110\111\105\100")animator=humanoid:WaitForChild("\065\110\105\109\097\116\111\114")humanoid.Touched:connect(h)humanoid.Died:connect(OnDie)SetWalkSpeed(0)local j=player.PlayerGui:WaitForChild("\083\116\097\114\116\083\099\114\101\101\110")if UserInputService.TouchEnabled==false then if UserInputService.GamepadEnabled then j.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 j.StartInstructions.StartLabel.Text="\080\114\101\115\115 \083\112\097\099\101 \116\111 \083\116\097\114\116"end end end local function c(h,c,j)if not startGame then return end if c==Enum.UserInputState.Begin then if j.KeyCode==Enum.KeyCode.Left then left=-1 moveDir=-1 elseif j.KeyCode==Enum.KeyCode.Right then right=1 moveDir=1 end SetWalkSpeed(moveSpeed)elseif c==Enum.UserInputState.End then if j.KeyCode==Enum.KeyCode.Left then left=0 elseif j.KeyCode==Enum.KeyCode.Right then right=0 end moveDir=left+right if moveDir==0 then SetWalkSpeed(0)end end end

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)

				if string.find(behaviours[i].Name, "Kill") then
					SmoothDie()
				end

			end
		end
	end
end

function characterAdded(newCharacter)
	ResetGame()
	bindFuc:Invoke(true)
	character = player.Character
	humanoid = character:WaitForChild("Humanoid")
	animator = humanoid:WaitForChild("Animator")
	humanoid.Touched:connect(characterTouchedBrick)
	humanoid.Died:connect(OnDie)
	SetWalkSpeed(0)

	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
end




local function MoveAction(actionName, inputState, inputObject)
	if(not startGame) then
		return
	end

	if inputState == Enum.UserInputState.Begin then
		if inputObject.KeyCode == Enum.KeyCode.Left then
			left = -1
			moveDir = -1
		elseif inputObject.KeyCode == Enum.KeyCode.Right then
			right = 1
			moveDir = 1
		end
		SetWalkSpeed(moveSpeed)
	elseif inputState == Enum.UserInputState.End then
		if inputObject.KeyCode == Enum.KeyCode.Left then
			left = 0
		elseif inputObject.KeyCode == Enum.KeyCode.Right then
			right = 0
		end
		moveDir = left + right
		if moveDir == 0 then
			SetWalkSpeed(0) 
		end

	end
end
