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

Running animations in other players?

Asked by
neoG457 315 Moderation Voter
9 years ago
    enabled = true
local function OnTouched(hitPart)
if not enabled then
            return
    end

enabled = false

local plyr = hitPart:FindFirstChild("Humanoid")
if plyr then

local Suffocate = Instance.new("Animation")
    Suffocate.AnimationId = "http://www.roblox.com/Asset?ID=276272282"
local animTrack = plyr:LoadAnimation(Suffocate)
        animTrack:Play()    



end
end
OxygenSuckDMG.Touched:connect(OnTouched)

I want to play an animation in Players when they touch the part called OxygenSuckDMG however it will not work. Pls help.

1 answer

Log in to vote
1
Answered by 9 years ago
    enabled = true
local function OnTouched(hitPart) -- hitPart will return the part that touched it, not the character of the player.
if not enabled then
            return
    end

enabled = false -- I'm not sure if this is supposed to be a debounce or it is supposed to be a one time only thing, so I'll leave you to tinker with that.

if plyr.Parent:findFirstChild("Humanoid") then -- Since you made Humanoid a local object then if it's not found it will return an error.

local Suffocate = Instance.new("Animation")
    Suffocate.AnimationId = "http://www.roblox.com/Asset?ID=276272282"
local animTrack = plyr:LoadAnimation(Suffocate)
        animTrack:Play()    



end
end
OxygenSuckDMG.Touched:connect(OnTouched)

Ad

Answer this question