Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Running animations in other players?

	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

    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)

This discussion is preserved as it was. New answers, comments, and votes are closed.