So basically, I am working on reconstructing an open source mini games game by completely upgrading it to a more modern roblox style of playing. Right now I am trying to switch all of the game messages (ex: Next mini game starting in...) from a black hint at the top of the screen to a Screen Gui in the PlayerGui. I need someone to point out my mistake in this code because it is not working properly.
function displayMSG(string, parent, time) local msg = game.PlayerGui.Text.TextBG.Text msg.Parent.Parent.Parent.Parent = parent msg.Text = string wait(time) msg:remove() end function displayHINT(string, parent, time) local msg = game.PlayerGui.Text.TextBG.Text msg.Parent.Parent.Parent.Parent = parent msg.Text = string if time ~= nil then wait(time) msg:remove() end end
I know for sure that the code isn't written properly, so any help would be great! Thanks!
This is a bad way of doing it. This code is more efficient. First create a string value in replicated storage and name it "MSG" Next use this code to change the text. This script is supposed to be in the textlabel. The gui is supposed to be in the StarterGui.
local msg = game.ReplicatedStorage.MSG local txt = script.Parent function Change() txt.Text = msg.Value --Changes text to your message end) Change() --Calls the function to run. msg.Changed:connect(Change) --Runs the function every time the value changes.
What this will do is when you change the value of MSG it will change the text every time it changes. So, I would set MSG's value to nothing then change the value from a script in ServerScriptService. Hope this helped you. I'm making a youtube tutorial for this minigame stuff soon. Do this for your hint value as well. ~Spooksletsky @Spooksletsky