Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i make a Animation Play When A Part Is Touched?

Asked by 4 years ago

Hello so i am trying to do this script ~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~local anime = script.Parent.name.Value local brick = script.Parent local debounce = false

function onTouch(plr) if not debounce then local hum = game.Players:GetPlayerFromCharacter(plr.Parent) local humanoid = plr.Parent:FindFirstChild("Humanoid") local anim_load = humanoid:LoadAnimation(script.Parent.Animation) local current = anim_load current:Play() debounce = true end wait(3) debounce = false end brick.Touched:connect(onTouch)**** So anyways the script wont work, and the script is in a part and when i touch it i want a animation plays. Please reply

0
Is this a local script or a normal script? Twinbrotato 543 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

do this inside a serverscript inside the part

local debounce = false
-- Inside a serverScript btw
part.Touched:Connect(function(hit)
    if not debounce then
        if hit.Parent:FindFirstChild("Humanoid") then
            debounce = true
            local humanoid = hit.Parent.Humanoid -- Getting the humanoid
            humanoid:LoadAnimation(youranimationhere):Play() -- Playing the animation
            wait(2)
            debounce = false
        end
    end
end)
0
Thanks! It worked! sorry for late reply :P AmeerAlM 4 — 3y
Ad

Answer this question