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

Why doesn't anything happen when a player touches this brick?

Asked by
Seraine 103
8 years ago

They should perform an animation but at the moment nothing happens when the brick is touched.

1function onTouched(hit)
2    local h = hit.Parent:findFirstChild("Humanoid")
3    if h ~= nil then
4        local anim = Instance.new("Animation")
5        anim.AnimationId = "rbxassetid://29517689"
6        anim:Play()
7    end
8end
9script.Parent.Touched:connect(onTouched)
1
You never load the animation. User#11440 120 — 8y
1
How do I load the animation? Seraine 103 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

You forgot to load your animation into the humanoid.

01function onTouched(hit)
02    local h = hit.Parent:findFirstChild("Humanoid")
03    if h ~= nil then
04        local anim = Instance.new("Animation")
05        anim.AnimationId = "rbxassetid://29517689"
06        local animLoad = h:LoadAnimation(anim) -- An animation has to be loaded into the humanoid
07        animLoad:Play()
08    end
09end
10script.Parent.Touched:connect(onTouched)
1
Thank youu!!! Seraine 103 — 8y
Ad

Answer this question