Hello there! So recently I wanted to make a screaming effect that happens when you click a button and an animation plays with two sounds that will randomly play every time you click the button with the players face changing and then going back to normal.
So far, I have looked at a YouTube video but that didn’t help.
Here is my current script (Note I haven’t written too much because I’m not relatively good at this stuff)
local player = game.Players.LocalPlayer
local character = player.Character
local hum = character.Humanoid
local Sound1 = workspace.Shiba
local Sound2 = workspace.Scream
local Animation = game.StarterGui.Scream.TextButton.Scream
local AnimationTrack = hum:LoadAnimation(Animation)
I’m not asking for whole scripts or anything I just don’t know what to write next as I am not good with scripting. I hope you understand
If you need more information, give me a sign
Thanks for reading
Have you tried waiting for the right keytrack and then changing the face/playing the sound?
for example if you want the character to change their face .5 seconds after the animation plays you can do
local player = game.Players.LocalPlayer
local character = player.Character
local hum = character.Humanoid
local Sound1 = workspace.Shiba
local Sound2 = workspace.Scream
local Animation = game.StarterGui.Scream.TextButton.Scream
local AnimationTrack = hum:LoadAnimation(Animation)
local face = character.Head.face
local OriginalTexture = face.Texture
AnimationTrack:play()
wait(.5)
face.Texture = "" -- id of the face you want
wait(.5)
face.Texture = OriginalTexture
1 Like
What im trying to do is make the face change when the animation starts and revert back to normal when it ends
Oh nevermind i just reread the script
Then all you need to do is
AnimationTrack:play()
face.Texture = "" -- id you want
AnimationTrack.Stopped:wait()
face.Texture = OriginalTexture
1 Like
Okay so I had edited the script a bit, the animation worked before but sound or face isnt changing
local soounds = game:GetService("SoundService").Sounds:GetChildren()
local player = game.Players.LocalPlayer
local character = player.Character
local hum = player.Character:WaitForChild("Humanoid")
local Animation = game.StarterGui.Scream.TextButton.Scream
local AnimationTrack = hum:LoadAnimation(Animation)
local face = character.Head.face
local OriginalTexture = face.Texture
local button = script.Parent
local sounds = {
9940742886;
9940743080;
}
button.MouseButton1Click:Connect(function()
local RandomSound = sounds[math.random(1, #sounds)]
AnimationTrack:play()
RandomSound:Play()
face.Texture = "9940645813"
wait()
face.Texture = OriginalTexture
end)
1 Like
Also the animation is looped and doesnt stop after sound is played (which doesnt really play in this case) (Sorry if it feels as if im bothering you)
local Sound1 = script.workspace.Shiba
local Sound2 = script.workspace.Scream -- i know your sounds aren't in workspace anymore, this is just an example
local SoundArray = {Sound1,Sound2}
button.MouseButton1Click:Connect(function()
local RandomSound = SoundArray[math.random(1,2)]
AnimationTrack:play()
RandomSound:Play()
face.Texture = "rbxassetid://9940645813"`-- add this to the id
AnimationTrack.Stopped:wait() -- if you just do wait() the face will revert to normal almost instantly
face.Texture = OriginalTexture
end)