-
What do you want to achieve? Keep it simple and clear!
I want to achieve a sleep animation that looks like,
Currently, it looks like:
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried to find a solution, but I’m confused with euler angles, and such. Also, I don’t know how to make the angle dependent on the angle of the bed.
local pps = game:GetService("ProximityPromptService")
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local Animator = humanoid:WaitForChild("Animator")
local hrp = char:WaitForChild("HumanoidRootPart")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://10214821046"
local Track = Animator:LoadAnimation(animation)
Track.Priority = Enum.AnimationPriority.Action
Track.Looped = true
local function onPromptTriggered(prompt, player)
if prompt.Name == "Sleep" then
local bed = prompt.Parent
prompt.Enabled = false
hrp.Anchored = true
hrp.CFrame = CFrame.new(prompt.Parent.Position + Vector3.new(0,4,0))
Track:Play()
bed.Wake.Enabled = true
elseif prompt.Name == "Wake" then
local bed = prompt.Parent
prompt.Enabled = false
bed.Sleep.Enabled = true
Track:Stop()
hrp.Anchored = false
end
end
pps.PromptTriggered:Connect(onPromptTriggered)