Untitled
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local part = script.Parent -- Change to the obstacle part part.Touched:Connect(function(hit) local hitCharacter = hit.Parent local hitHumanoid = hitCharacter:FindFirstChildOfClass("Humanoid") if hitHumanoid and hitCharacter == character then humanoid.Health = 0 end end) local function onKeyPress(input) if input.KeyCode == Enum.KeyCode.Space then humanoid:ChangeState(Enum.HumanoidStateType.Jumping) end end game:GetService("UserInputService").InputBegan:Connect(onKeyPress)
Leave a Comment