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

Can someone help with displaying text using a Screen Gui in my Mini-games game?

Asked by
GunCoo 0
8 years ago

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!

0
You never called your functions. koolkid8099 705 — 8y
0
make sure you loop through every player too ProfessorSev 220 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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

Ad

Answer this question