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

Freeze NPC at a specific spot?

Asked by 3 years ago
Edited 3 years ago

Hello. I am trying to freeze the animation at a specific spot when the player goes near the NPC. The animation works but it doesn't freeze at the marker I put.

Script:

local Players = game:GetService("Players")

local Main = script.Parent local Humanoid = Main:FindFirstChildOfClass("Humanoid")

local Range = 26 -- Range local Check = true -- Debouncer

local PlayAnimation = function(AnimationID) local Animation = Instance.new("Animation") Animation.AnimationId = ("rbxassetid://%s"):format(AnimationID)

local Track = Humanoid:LoadAnimation(Animation)
Track:Play()

end

while wait() and Check do for _,Player in next, Players:GetPlayers() do local Char = Player.Character or Player.CharacterAdded:wait() local HumanoidRootPart = Char:FindFirstChild('HumanoidRootPart') local A,B = HumanoidRootPart.Position, Main.HumanoidRootPart.Position

    local Dist = (A - B).Magnitude
    if Dist <= Range then 
        PlayAnimation(6952695615)
        Check = false
        wait(55)
        Check = true
    end
end

end

PlayAnimation:GetMarkerReachedSignal("Freeze"):Connect(function() PlayAnimation:AdjustSpeed(0) end)

0
you can anchor an npc once it touches the specific part Xyternal 247 — 3y

1 answer

Log in to vote
0
Answered by
epoke466 100
3 years ago

Like Xyternal said: you can anchor the torso of the ncp so it does not move after the player touches a specific part. If you wanted to unfreeze it just unanchor the torso. This will make the npc not able to move back and forth.

If you wanted to completely freeze it so the its arms, legs, and head do not move you will have to anchor them too.

If you wanted to freeze everything but, lets say the right arm then anchor everything but the right arm.

If the player has to be a certain distance from the npc and the npc moves around, you can weld the part the player touches to the npc's humanoid root part. Make sure that the part is unanchored so that the npc can move.

Ad

Answer this question