Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make it so when the player stops moving they die?

Asked by 5 years ago

basically as the title explains, When a player stops moving for more than a second they die, is there anyway to make that?

3 answers

Log in to vote
0
Answered by 5 years ago

Here

if Humanoid.MoveToDirection.Magnitude == 0 then
    --kill
end
Ad
Log in to vote
0
Answered by 5 years ago

Insert in a local script and place in the player.

local player = game.Players.LocalPlayer

while wait(1) do
    if player.Character.HumanoidRootPart.Velocity.Magnitude < 1 then
        wait(1)
        if player.Character.HumanoidRootPart.Velocity.Magnitude < 1 then
            player.Character.Humanoid.Health = 0
        end
    end
end
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You can use the Running event in the humanoid.

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local humanoid = character:WaitForChild("Humanoid")
        humanoid.Running:connect(function(speed)
            if speed > 0 then 
                print("player is walking")
            else
                character:BreakJoints() --same thing as Humanoid.Health = 0
            end
        end)
    end)
end)

Answer this question