Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Hello people of scriptinghelpers! I need some help with my talking script?

Asked by
Lakodex 711 Moderation Voter
4 years ago
Edited 4 years ago

Fixed! Thank you youtube master wow, I had to put a modification at the end to make it not glitch out and be weird, thank you!

while true do
    wait()
    if game.Workspace.NPC.Head.speach.PlaybackLoudness <= 65 then
        game.Workspace.NPC.Head.Mouth.Texture = "rbxassetid://2801767831"
    elseif game.Workspace.NPC.Head.speach.PlaybackLoudness <= 75 and game.Workspace.NPC.Head.speach.PlaybackLoudness > 65 then
        game.Workspace.NPC.Head.Mouth.Texture = "rbxassetid://2801751501"
    elseif game.Workspace.NPC.Head.speach.PlaybackLoudness <= 85 and game.Workspace.NPC.Head.speach.PlaybackLoudness > 75 then
        game.Workspace.NPC.Head.Mouth.Texture = "rbxassetid://845217767"
    elseif game.Workspace.NPC.Head.speach.PlaybackLoudness <= 95 and game.Workspace.NPC.Head.speach.PlaybackLoudness > 85 or game.Workspace.NPC.Head.speach.PlaybackLoudness > 75 then
        game.Workspace.NPC.Head.Mouth.Texture = "rbxassetid://907601394"
    end
end
0
If this is a Server Script, then PlaybackLoudness will always be 0 since there is no audio output on the Server, this needs to be run from the Client, use a LocalScript SerpentineKing 3885 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

Hello. The problem is that you wrote <= which means less than or equal to. This would not work as 75, 85, and 95 are greater than 65. Try adding a simple and statement that checks if it's louder than the other if statements.

while true do
    wait()
    if script.Parent.speach.PlaybackLoudness <= 65 then
        script.Parent.Mouth.Texture = "rbxassetid://2801767831"
    elseif script.Parent.speach.PlaybackLoudness <= 75 and  script.Parent.speach.PlaybackLoudness > 65 then
        script.Parent.Mouth.Texture = "rbxassetid://2801751501"
    elseif script.Parent.speach.PlaybackLoudness <= 85 and  script.Parent.speach.PlaybackLoudness > 75 then
        script.Parent.Mouth.Texture = "rbxassetid://845217767"
    elseif script.Parent.speach.PlaybackLoudness <= 95 and  script.Parent.speach.PlaybackLoudness > 85 then
        script.Parent.Mouth.Texture = "rbxassetid://907601394"
    end
end

Please accept and upvote this answer if it helped.

0
Your edit is unnecessary, say for example PlaybackLoudness is 80, on the first condition, 80 > 65, the statement returns false, on the second condition 80 > 75, again returning false, the next condition, 80 < 85 so it returns true and updates the texture SerpentineKing 3885 — 4y
Ad

Answer this question