#can some one fix mky script for me pls bc i cant get it working

1 messages · Page 1 of 1 (latest)

dusky sierra
#

local part = script.Parent
local animation = workspace.Rig:FindFirstChildOfClass("Animation")

part.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
if humanoid and animation then
local animTrack = humanoid:LoadAnimation(animation)
animTrack:Play()
end
end)

#

its supposed to make an animation play when the part is touched

potent adder
#

are you getting

#

any errors?

dusky sierra
#

well yes the animation isnt playing when i touch the part

potent adder
#

on the

#

console?

dusky sierra
#

i dont think so

#

ive never done this befor so

potent adder
#

touch the part

#

and then

#

press f9 on

#

your keyboard

dusky sierra
#

ok

potent adder
#

and see if theres any red text

dusky sierra
#

thats what i got but dont know how to fix it

formal terraceBOT
#

studio** You are now Level 1! **studio

potent adder
#
local part = script.Parent:WaitForChild("Humanoid")
local animation = workspace.Rig:FindFirstChildOfClass("Animation")

part.Touched:Connect(function(hit)
    local character = hit.Parent
    local humanoid = character and character:FindFirstChildOfClass("Humanoid")
    if humanoid and animation then
        local animTrack = humanoid:LoadAnimation(animation)
        animTrack:Play()
    end
end)
#

can you replace this

#

with your code?

dusky sierra
#

ok

#

it didnt work

potent adder
#

any errors?

dusky sierra
potent adder
#

who do you want to

#

play the animation

#

your character

#

or the rig?

dusky sierra
#

no the rig

potent adder
#

well, you did it wrong.

#

hold on

#

i gotchu

dusky sierra
#

oh

#

ok

potent adder
dusky sierra
#

in the rig

steep tundra
#

use animator

#

nro

#

beo

#

bro

potent adder
#

humanoid works too

#

its just deprecated.

steep tundra
#

local part = script.Parent
local animation = workspace.Rig:FindFirstChildOfClass("Animation")

part.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
if humanoid and animation then
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
local animTrack = animator:LoadAnimation(animation)
animTrack:Play()
end
end
end)

potent adder
#
local rig = script.Parent
local humanoid = rig:WaitForChild("Humanoid")
local animation = rig:FindFirstChildOfClass("Animation")
local db = false

part.Touched:Connect(function(hit)
    if db then return; end
    if not animation then print("animation in rig not found") return; end
    local animTrack = humanoid:LoadAnimation(animation)
    animTrack:Play()
end)
#

replace this with your code

#

and see if it prints anything

dusky sierra
#

ok

potent adder
#

on the f9 console.

dusky sierra
#

thats what i got

potent adder
#

my bad

#
local rig = script.Parent
local humanoid = rig:WaitForChild("Humanoid")
local animation = rig:FindFirstChildOfClass("Animation")
local db = false

humanoid.Touched:Connect(function(hit)
    if db then return; end
    if not animation then print("animation in rig not found") return; end
    local animTrack = humanoid:LoadAnimation(animation)
    animTrack:Play()
end)
#

try with this one

dusky sierra
formal terraceBOT
#

studio** You are now Level 2! **studio

dusky sierra
#

i think something else is wrong

potent adder
#

in the rig

#

That is a

#

animation?

dusky sierra
#

idk

#

thats wat i did

potent adder
#
local rig = script.Parent
local humanoid = rig:WaitForChild("Humanoid")
local animation = script:WaitForChild("Animation")
local db = false

humanoid.Touched:Connect(function(hit)
    if db then return; end
    if not animation then print("animation in rig not found") return; end
    local animTrack = humanoid:LoadAnimation(animation)
    db = true
    task.delay(2, function()
       db = false
    end)
    animTrack:Play()
end)
#

try this

dusky sierra
#

it doesnt say anything in the f9 console but the anim plays when i enter the game

#

@potent adder can you fix this?

potent adder
#
local rig = script.Parent
local humanoid = rig:WaitForChild("Humanoid")
local animation = script:WaitForChild("Animation")
local db = false

humanoid.Touched:Connect(function(hit)
    if db then return; end
    if not hit.Parent:FindFirstChild("Humanoid") then return; end
    if not animation then print("animation in rig not found") return; end
    local animTrack = humanoid:LoadAnimation(animation)
    db = true
    task.delay(2, function()
       db = false
    end)
    animTrack:Play()
end)
#

try this.

#

@dusky sierra

dusky sierra
#

k

#

still nothin

#

i feel like its not the script at this point

steep tundra
# dusky sierra still nothin

local part = script.Parent
local animation = workspace.Rig:FindFirstChildOfClass("Animation")

part.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
if humanoid and animation then
local animator = humanoid:FindFirstChildOfClass("Animator")
if animator then
local animTrack = animator:LoadAnimation(animation)
animTrack:Play()
end
end
end)

#

try this

dusky sierra
steep tundra
dusky sierra
#

what you mean

steep tundra
dusky sierra
#

yes

#

@steep tundra @potent adder can you guys fix it?

steep tundra
#

local part = script.Parent
local animation = workspace.Rig:FindFirstChild("MyAnimation")
local debounce = {}

part.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character and character:FindFirstChildOfClass("Humanoid")

if humanoid and animation and not debounce[character] then
    debounce[character] = true

    local animator = humanoid:FindFirstChildOfClass("Animator")
    if animator then
        local animTrack = animator:LoadAnimation(animation)
        animTrack:Play()

        animTrack.Stopped:Connect(function()
            debounce[character] = nil
        end)
    else
        debounce[character] = nil
    end
end

end)

dusky sierra
#

able to fix? @steep tundra

formal terraceBOT
#

studio** You are now Level 3! **studio

steep tundra
#

used the part in part

#

cause theres no touched on rig

dusky sierra
#

huh

#

@steep tundra what you mean

dusky sierra
#

i give up