I need a script that plays an custom animation when player sit on chair.
And I also need one of two animations to play when the player sits on a chair (50/50)
Don’t send me roblox docs
1 Like
local chair = script.Parent -- Reference to the chair part
local anim1Id = "rbxassetid://<Animation1ID>"
local anim2Id = "rbxassetid://<Animation2ID>"
chair.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.Seated:Connect(function(isSeated, seat)
if isSeated and seat == chair then -- Check if the player is sitting on this specific chair
local randomAnim = math.random(1, 2)
local animId = (randomAnim == 1) and anim1Id or anim2Id
local animation = Instance.new("Animation")
animation.AnimationId = animId
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
end
end)
end
end)
put this as a direct child inside your chair
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.