#animation didnt want to stop so if someone can help me pls :( @ me if u need more screen :c
1 messages · Page 1 of 1 (latest)
where do i put this 
stop the animation when the bed is Destroyed or something
or the Tool is Unequipped
i don't know :/ i just want the animation stop the animation i have tried to stop with the script but there is nothing said that the bed destroy
okok
why are you writing it like this 😭
because the script is too big
so discord says no
that why i think
local Players = game:GetService("Players")
local lp = Players.LocalPlayer
local Tool = script.Parent
local Anim = script:FindFirstChild("Idle")
-- Wait for character and humanoid to be ready
local character = lp.Character or lp.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", humanoid)
-- Load the animation
local Loaded = animator:LoadAnimation(Anim)
local Weld = nil
-- Attach Zone part above player's head
local function attachAboveHead()
local head = character:FindFirstChild("Head")
local zone = Tool:FindFirstChild("Zone")
if not head or not zone then return end
-- Remove existing welds
for _, w in ipairs(zone:GetChildren()) do
if w:IsA("WeldConstraint") then
w:Destroy()
end
end
-- Create new weld
Weld = Instance.new("WeldConstraint")
Weld.Name = "AboveHeadWeld"
Weld.Part0 = zone
Weld.Part1 = head
Weld.Parent = zone
-- Position zone above the head
local offset = Vector3.new(0, 1.5, 0)
zone.CFrame = head.CFrame * CFrame.new(offset)
zone.Anchored = false
end
-- Detach Zone from head
local function detachFromHead()
local zone = Tool:FindFirstChild("Zone")
if zone then
for _, w in ipairs(zone:GetChildren()) do
if w:IsA("WeldConstraint") and w.Name == "AboveHeadWeld" then
w:Destroy()
end
end
end
end
-- Handle Equip
local function Equipped()
if not Loaded then
Loaded = animator:LoadAnimation(Anim)
end
Loaded:Play()
attachAboveHead()
end
-- Handle Unequip
local function Unequipped()
if Loaded then
Loaded:Stop()
end
detachFromHead()
end
-- Bind events
Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)
-- If tool is already equipped when script runs
if Tool.Parent == character then
Equipped()
end
u sure ?
lol