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)
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.