Well im trying to make a player press e (promixty prompt) to open a door and then a player animation will play with it
I tried some free models scripts and but none of them works
-any help will be appreciated
–Thanks!
2 Likes
Use ProximityPrompt.Triggered
and Humanoid:LoadAnimation()
Example code:
local ProximityPrompt = path.to.prompt
ProximityPrompt.Triggered:Connect(function(player)
local character = player.Character
local humanoid = character:WaitForChild("Humanoid") or character:FindFirstChild("Humanoid")
humanoid:LoadAnimation(animation_here)
end)
1 Like
Dose not work for me i dont know why
here is the script i puted it to
script.Parent.Part.CD.Triggered:Connect(function(player)
player.Character:SetPrimaryPartCFrame(CFrame.lookAt(player.Character.HumanoidRootPart.Position,script.Parent.dir.Position))
player.Character.HumanoidRootPart.Position = script.Parent.Parent.Parent.Destination.Position
wait(1)
player.Character.HumanoidRootPart.Anchored = true
local character = player.Character
local humanoid = character:WaitForChild("Humanoid") or character:FindFirstChild("Humanoid")
local anim = humanoid:LoadAnimation(script.Parent.Part.Animation1)
wait(0.1)
script.Parent.GUI:Clone().Parent = player.PlayerGui
end)
script.Parent.GUI.TextButton.V.Value = script.Parent
Any errors in the console?
Have you added print()
to check if your prompt is triggering or not?
no errors and everything works fine in it just the animation wont play
You are not playing the animation.
local anim = humanoid:LoadAnimation(script.Parent.Part.Animation1)
anim:Play() -- Add this line
Click for Code If needed.
script.Parent.Part.CD.Triggered:Connect(function(player)
player.Character:SetPrimaryPartCFrame(CFrame.lookAt(player.Character.HumanoidRootPart.Position,script.Parent.dir.Position))
player.Character.HumanoidRootPart.Position = script.Parent.Parent.Parent.Destination.Position
wait(1)
player.Character.HumanoidRootPart.Anchored = true
local character = player.Character
local humanoid = character:WaitForChild("Humanoid") or character:FindFirstChild("Humanoid")
local anim = humanoid:LoadAnimation(script.Parent.Part.Animation1)
anim:Play()
wait(0.1)
script.Parent.GUI:Clone().Parent = player.PlayerGui
end)
1 Like
Thanks! now it works
did not know that it needed to play