#Anim Play at touching part

100 messages · Page 1 of 1 (latest)

ornate hawk
#

this should actually error

#

unless that's an npc

#

ofc

#

if Mary.TouchDetector.Touched then
touched is an event

#

this is a very odd way to code this, what's your setup?

glossy sigil
#

I'm really bad at scripting- I don't know really about it

rotund heart
#

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

ornate hawk
glossy sigil
#

Im trying make when player touches the part inside her she plays animation

ornate hawk
#

it should work

#

AH

#

yeah

#

that will totally not work

#

let's go over why first

#
local Mary = game.Workspace.Mary

if Mary.TouchDetector.Touched then
Mary.Humanoid.Animator:LoadAnimation(Mary.Stand):Play()

if Mary.Stand.IsPlaying == true then 
    Mary.Stand.Looped = true
end
end
#

that code will run exactly once

#

inmediately after you clicked the run button

#

the script then will proceed to commit suicide

#

literally

#

if you want the script to not die

#

you have to connect to the event!

glossy sigil
#

How i do that-

ornate hawk
#
local TouchDetector = workspace.TouchDetector
TouchDetector.Touched:Connect(function(touchedPart)
  
end)
#

second thing

#

local Mary = game.Workspace.Mary

#

remember I said that the script will run inmediately?

ornate hawk
#

well the player takes at the very least 3 seconds to load

#

it's not gonna be there

ornate hawk
#

so you gotta get the player from the touched part

glossy sigil
#

omg ty

ornate hawk
#

you cannot just fetch it from the workspace basically

ornate hawk
#

and noo worries

#

ez way to get the player from the touched part

glossy sigil
ornate hawk
#

nope

glossy sigil
#

oh

ornate hawk
#

is mary the parent of the script?

glossy sigil
#

yeah

ornate hawk
#

wait what?

glossy sigil
#

and the aprent of the detector

ornate hawk
#

isn't mary your character?

glossy sigil
ornate hawk
#

huh

glossy sigil
ornate hawk
#

interesting

#

I'm very confused now

#

send image of your workspace

#

in studio

glossy sigil
#

kk

ornate hawk
#

to play with it around ig

#

literally a model of your character

glossy sigil
glossy sigil
#

its like-

#

player touches the detector

#

then she plays anim

ornate hawk
#

Oh lmao

#

then yeah absolutely

#
local TouchDetector = workspace.TouchDetector
local Mary = script.Parent
TouchDetector.Touched:Connect(function(touchedPart)
    Mary.Humanoid.Animator:LoadAnimation(Mary.Stand):Play()
end)
#

should do it?

glossy sigil
#

she dissapeared-

#

help

ornate hawk
#

okay. that is very lol

#

right...

#

we are not checking anything

#

heehh

#

we still gotta check if a player touched her (oh no)

glossy sigil
ornate hawk
#

yeah but the code will trigger for absolutely antything that touches mary

#

including the baseplate

#

we are not discriminating, basically

#
local Players = game:GetService("Players")
local TouchDetector = workspace.TouchDetector
local Mary = script.Parent

TouchDetector.Touched:Connect(function(touchedPart)
    local Character = touchedPart.Parent
    if not Character then return end

    local Player = Players:GetPlayerFromCharacter(Character)
    if not Player then return end
    
    Mary.Humanoid.Animator:LoadAnimation(Mary.Stand):Play()
end)
glossy sigil
#

huh?

#

OH

ornate hawk
#

still not debouncing so the animation could play many times

glossy sigil
#

Help she just dissapears when play

#

oh

#

sorry- i tried the other and now i see the edit

glossy sigil
#

kk

#

she stills dissapearing rip

ornate hawk
#

LMAO

#

that's pretty weird ngl

glossy sigil
#

fr

ornate hawk
#

is she anchored or is she set non collidable?

glossy sigil
#

shes not anchored

#

and you can collide

#

i will try with another model

#

probably its a model problem ig

ornate hawk
#

it could be, hopefully that helps

#

anyways the script is sound though so you can just re-use it

glossy sigil
#

kk tysm

#

ty for help

ornate hawk
#

noo worries

#

good luck