I'm trying to make a model of mine appear to be talking like an actual player, so it talks both in the chat and also has a bubble chat above its head. (The model doesn't have anything special to it, there is actually an invisible talking dummy that is lined up with my model's head so it looks like my model is talking) Both scripts have the same timing, but I came across an annoying problem when playing the game.
The chat bar isn't in sync with the bubble chat despite being the same timing. I'm assuming it's because of the time it takes for a player to load in, resulting in one script running before the other.
Is there a way I could get both scripts to synchronize?
The script for the bubble chat is placed in a dummy with humanoid (the script itself isn't in the humanoid) and I made the dummy parts invisible and not collidable as if there was no dummy at all, making it appear that my model is actually talking. Here's the script for that (not the complete script, just the beginning, and end).
while true do wait(3) --time till it speaks the message below game:GetService("Chat"):Chat(script.Parent.Head, "Oh...", Enum.ChatColor.White) --first thing it says wait(6) game:GetService("Chat"):Chat(script.Parent.Head, "Hello there.", Enum.ChatColor.White) wait(1) game:GetService("Chat"):Chat(script.Parent.Head, "", Enum.ChatColor.White) --the only way to make it stop speaking or else it would loop for some reason end
My next script, where he talks in the actual chat, is placed in StarterPlayerScripts. Here is the script for that.
Wait (3) --timing is the same as above game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ --it gets the StarterGui and calls a function Text = "[Dipper]: Oh..."; --model name and message Color = Color3.new(0, 0, 200); --this is just color, ignore this FontSize = Enum.FontSize.Size24; --font, ignore }) --below is the same thing but different message, and it just goes on and on Wait(6) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = "[Dipper]: Hello there."; Color = Color3.new(0, 0, 255); FontSize = Enum.FontSize.Size24; })
Hopefully, there is a script I can do so that these two scripts are in sync. If you're confused with anything, here's the game so you have a better picture of what's going on and help me. http://www.roblox.com/games/4714225379/A-Talk-With-Dipper-wip
Thank you for any help.
Just keep one script. Its overall better. Use spawn() to run a loop and some code at the same time.
spawn(function() while true do print('Spawn functions allow you to run 2 loops at the same time!') end end) spawn(function() while true do print('I use spawns in every single fps game I make!') end end) spawn(function() while true do print('Try it!') end end)
Heres a full script:
spawn(function() while true do wait(3) --time till it speaks the message below game:GetService("Chat"):Chat(script.Parent.Head, "Oh...", Enum.ChatColor.White) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = "[Dipper]: Oh..."; Color = Color3.new(0, 0, 200); FontSize = Enum.FontSize.Size24; }) wait(6) game:GetService("Chat"):Chat(script.Parent.Head, "Hello there.", Enum.ChatColor.White) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = "[Dipper]: Hello there."; Color = Color3.new(0, 0, 255); FontSize = Enum.FontSize.Size24; }) wait(1) game:GetService("Chat"):Chat(script.Parent.Head, "", Enum.ChatColor.White) break -- Ends the loop. But why put it in a loop anyways? end end) -- Putting it in a loop was kinda stupid, so... wait(3) --time till it speaks the message below game:GetService("Chat"):Chat(script.Parent.Head, "Oh...", Enum.ChatColor.White) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = "[Dipper]: Oh..."; Color = Color3.new(0, 0, 200); FontSize = Enum.FontSize.Size24; }) wait(6) game:GetService("Chat"):Chat(script.Parent.Head, "Hello there.", Enum.ChatColor.White) game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage",{ Text = "[Dipper]: Hello there."; Color = Color3.new(0, 0, 255); FontSize = Enum.FontSize.Size24; }) wait(1) game:GetService("Chat"):Chat(script.Parent.Head, "", Enum.ChatColor.White)