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

How can I make the player's hip height increase to a specific amount when it is near a part?

Asked by 5 years ago

So my plan is to make a script that if you're near the red part your hip height is increased to a specific value, but if it is not it stays the same.

Diagram

0
have you even started to try AltNature 169 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

To do this you want to use Magnitude to get the distance between the player and the part. Check out the Developer wiki on it here but i attempted this and i got a good result.

local Part = game.Workspace:WaitForChild("HipHeightPart")

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)

        while wait() do
            local Magnitude = (char.Torso.Position - Part.Position).Magnitude
            if Magnitude <= 10 then
                char.Humanoid.HipHeight = 5
            else
                char.Humanoid.HipHeight = 0 
            end
        end
    end)
end)
Ad

Answer this question