#Change of animation isn't working

1 messages · Page 1 of 1 (latest)

indigo cliff
#

I have a custom animation for idle and walking and I made another where if you get below 50, these hurt animations play but it bugs and kind of combines the animations together instead of just playing the hurt animations when under 50 health

south wave
#

what is the animation priority for each animation? they should be set to the highest if you want them to play over the default animations (Action4)

indigo cliff
#

They were the normal idle and walk animations !!!

#

Should I set them both to action 4

mental thicketBOT
#

studio** You are now Level 4! **studio

south wave
#

yes

mental thicketBOT
#

studio** You are now Level 6! **studio

indigo cliff
#

Alright, i've done that but the problem remains

#

`local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local idleAnimation = game.ReplicatedStorage:FindFirstChild("LowHealthIdleAnimation")
local walkAnimation = game.ReplicatedStorage:FindFirstChild("LowHealthWalkAnimation")
local loadedIdleAnimation = humanoid:LoadAnimation(idleAnimation)
local loadedWalkAnimation = humanoid:LoadAnimation(walkAnimation)

while wait() do
if humanoid.Health <= 50 then
loadedIdleAnimation:Play()
loadedWalkAnimation:Play()
else
loadedIdleAnimation:Stop()
loadedWalkAnimation:Stop()
end
end`

#

That's the code inside replicated storage

south wave
#

i need a little more information - when the script runs the animations don't play, fine. but do the regular default animations play at under 50%?

indigo cliff
#

I think they still do ?

midnight crypt
#

or a server script?

lean hearth
#

Hi

south wave
#

this is probably local

indigo cliff
midnight crypt
#

try a local script

south wave
#

you need this to be a localscript

midnight crypt
#

scripts are for server systems

#

which works for all players

#

at the same time

#

we dont need that

#

for animations

#

animations can be handled from the client side

indigo cliff
#

I put it as a local script but the problem still is occuring

midnight crypt
#

Any errors?

indigo cliff
#

No, none come up

midnight crypt
#

Since its a client script

#

You can use runservice instead of while

#

its way better

#

i think the problem is the while loop.

indigo cliff
#

so instead of while just put runservice

south wave
#

i doubt the problem is the while loop

midnight crypt
#

you can find it in the docs

#

but make sure not to play the animation every frame

#

only play it if its not playing

indigo cliff
#

its highlighted runservice in read

midnight crypt
#

wym

indigo cliff
#

runservice.renderstepped.wait() do

midnight crypt
#

no

#

not like that

#
game:GetService("RunService").RenderStepped:Connect(function()
--anything inside while loop goes here
end)
south wave
#

beat me to it, but yea ^

indigo cliff
#

The ) in end at the bottom is highlighted now

midnight crypt
#

theres a problem in your script

#

can you provide a full script?

#

ill do it for you.

indigo cliff
#

`local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local idleAnimation = game.ReplicatedStorage:FindFirstChild("LowHealthIdleAnimation")
local walkAnimation = game.ReplicatedStorage:FindFirstChild("LowHealthWalkAnimation")
local loadedIdleAnimation = humanoid:LoadAnimation(idleAnimation)
local loadedWalkAnimation = humanoid:LoadAnimation(walkAnimation)

game:GetService("RunService").RenderStepped:Connect(function()
if humanoid.Health <= 50 then
loadedIdleAnimation:Play()
loadedWalkAnimation:Play()
else
loadedIdleAnimation:Stop()
loadedWalkAnimation:Stop()
end)`

#

This is the full script :p

midnight crypt
#
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local idleAnimation = game.ReplicatedStorage:FindFirstChild("LowHealthIdleAnimation")
local walkAnimation = game.ReplicatedStorage:FindFirstChild("LowHealthWalkAnimation")
local loadedIdleAnimation = humanoid:LoadAnimation(idleAnimation)
local loadedWalkAnimation = humanoid:LoadAnimation(walkAnimation)

game:GetService("RunService").RenderStepped:Connect(function()
    if humanoid.Health <= 50 then
        if not loadedIdleAnimation.IsPlaying then
            loadedIdleAnimation:Play()
        end
        if not loadedWalkAnimation.IsPlaying then
            loadedWalkAnimation:Play()
        end
    else
        if loadedIdleAnimation.IsPlaying then
            loadedIdleAnimation:Stop()
        end
        if loadedWalkAnimation.IsPlaying then
            loadedWalkAnimation:Stop()
        end
    end
end)
#

Here you go.

south wave
#

i feel there should be more checks

midnight crypt
#

wym

south wave
#

as it stands i feel that if both aren't playing then it will try to play the idle - only to be overwritten by the walking animation

indigo cliff
#

I think thats just happened...

midnight crypt
#

do you want the walk animation

#

to play

#

only when moving?

indigo cliff
#

Mhm !!

midnight crypt
#

gotchu

#

1 sec

indigo cliff
#

Sorry that's my bad I should've made that clear

#

Thank you both so much for the help btw, i'm still getting used to scripting so it very helpful :]

midnight crypt
#
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local root = character:FindFirstChild("HumanoidRootPart")
local idleAnimation = game.ReplicatedStorage:FindFirstChild("LowHealthIdleAnimation")
local walkAnimation = game.ReplicatedStorage:FindFirstChild("LowHealthWalkAnimation")
local loadedIdleAnimation = humanoid:LoadAnimation(idleAnimation)
local loadedWalkAnimation = humanoid:LoadAnimation(walkAnimation)

game:GetService("RunService").RenderStepped:Connect(function()
    if humanoid.Health <= 50 then
        if not loadedIdleAnimation.IsPlaying then
            loadedIdleAnimation:Play()
        end
        if root.Velocity.Magnitude > 2 then
            if not loadedWalkAnimation.IsPlaying then
                loadedWalkAnimation:Play()
            end
        else
            if loadedWalkAnimation.IsPlaying then
                loadedWalkAnimation:Stop()
            end
        end
    else
        if loadedIdleAnimation.IsPlaying then
            loadedIdleAnimation:Stop()
        end
        if loadedWalkAnimation.IsPlaying then
            loadedWalkAnimation:Stop()
        end
    end
end)
mental thicketBOT
#

studio** You are now Level 14! **studio

midnight crypt
#

here you go

south wave
#

no problem man

indigo cliff
#

IT WORKS YIPPIEE TYTYTY

midnight crypt
#

🙂

#

great to hear

#

good luck

indigo cliff
#

Now i've got to sort out my other problem 😭

midnight crypt
#

hm

#

what is it

#

hope i can help

indigo cliff
#

It's so unrelated, want me dm you it so i can close this ?

midnight crypt
#

we can continue here

indigo cliff
#

okie

#

Well, i've made a shop person who you can chat to, he'll ask "Would you like to see the shop" (not the actual dialogue but its what he is asking) and you can reply "Yes" and after you press yes, the Dialogue UI closes and the shop UI opens

#

I've tried so many different scripts and ways but nothing works

midnight crypt
#

does the dialogue ui atleast appear?

indigo cliff
#

Yeah !!

midnight crypt
#

can i see your current code?

indigo cliff
#

For the dialogue ui closing ?

midnight crypt
#

your dialogue code.

#

not only closing.

indigo cliff
#

Okie, it's a kit thing I used for the ui and stuff but i understand it

#

`local dialogueKitModule = require(script.Parent.Parent.DialogueKit)
local dialoguePrompt = workspace:WaitForChild("DialoguePrompts"):WaitForChild("TestPrompt1").PromptPart.ProximityPrompt

dialoguePrompt.Triggered:Connect(function(player)
dialogueKitModule.CreateDialogue(
{
InitialLayer = "Layer1",
SkinName = "DefaultDark",
Config = script.Config,

        Layers = { 
            Layer1 = { 
                Dialogue = {
                    'Hey '..game.Players.LocalPlayer.Name.."!",
                    "I'm Serial Designation N, nice to meet you!",
                    "I sell drone skins, providing new mysterious abilites for you to explore !"
                },

                DialogueSounds = {nil, nil}, 
                DialogueImage = "rbxassetid://85352409508609", 
                Title = "Serial Designation N", 

                Replies = { 
                    reply1 = { 
                        ReplyText = "I'd like to purchase a skin", 
                        ReplyLayer = "Layer2" 
                    },

                    _goodbye = { 
                        ReplyText = "Thanks for the info, bye !",
                    }
                },

                Exec = { 
                }
            },

            Layer2 = { 
                Dialogue = {"Of course ! It'll cost you quite a bit though ! "},
                DialogueSounds = {},
                DialogueImage = "rbxassetid://85352409508609",
                Title = "Serial Designation N",

                Replies = {
                    
                },

                Exec = { 

                }
            },

        }
    }
)

end)`