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

How do I get a GUI to appear and disappear for everyone on the game?

Asked by 10 years ago

Well, I'm trying to edit this code I found and I'd like it to work for everyone, not just you in your PlayerGUI. How can I do that? This is the code for what will happen when a user pushes a button that activates this script. Oh, Local Values n, ti, d, and tl are all StringValues in workspace that the text is linked to change to whatever the value of those are.

local g = script.Parent
local f = g.Frame
local n = Workspace.username
local ti = Workspace.Title
local d = Workspace.desc
local tl = Workspace.TextLabel
local name = f.username
local desc = f.desc
local user = f.user
local t = f.TextLabel
people = { --[[Set up your people and there descriptions -  Must keep the descriptions under 36 characters]]
    ["name_1"] = "policecool",
    ["desc_1"] = "Our Founder And President",
    ["name_2"] = "Yuki990",
    ["desc_2"] = "Our Vice President And Head Anchorman",
    ["name_3"] = "soney1",
    ["desc_3"] = "Our CEO and Anchorwoman.",
    ["name_4"] = "anakinskywalker225",
    ["desc_4"] = "Our COO and Weatherman",
    ["name_5"] = "GirlsRule71",
    ["desc_5"] = "Our CDO and Head Backup Newscaster",
    ["name_6"] = "johsnic333",
    ["desc_6"] = "Our CMO and Secondary Backup Newscaster",
}

--Okay let's set the position and everything
f.Position = UDim2.new(1,0,0.7,0)
f.Size = UDim2.new(0.5, 0, 0.08, 0)
f.Visible = false
name.Visible = false
desc.Visible = false
user.Visible = false
f.Title.Visible = false
t.Visible = false
name.Position = UDim2.new(0,0,0.15,0)
desc.Position = UDim2.new(1,0,0.25,0)
user.Position = UDim2.new(0.6,0,0.5,0)
--Now let's get going
--Lets tween it to the main position
f:TweenSizeAndPosition(UDim2.new(0,400,0,400),UDim2.new(0.5,-200,0.5,-200),"In","Linear",2)
wait(2)
f.Visible = true
name.Visible = true
desc.Visible = true
user.Visible = true
f.Title.Visible = true
for i=1,50 do
    local test = people["name_" .. i]
    local desca = people["desc_" .. i]
    if test == nil then break end --This is a check to see if the table returned anything..
    n.Value = test
    d.Value = desca
    user.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=150&y=200&Format=Png&username=" .. test
    name:TweenPosition(UDim2.new(0.4,0,0.150000006,0),"Out","Linear",5,true)
    desc:TweenPosition(UDim2.new(0.62,0,0.25,0),"Out","Linear",5,true)
    user:TweenPosition(UDim2.new(0.1,0,0.3,0),"Out","Linear",5,true)
    wait(5)
    --Time to reset
    name.Position = UDim2.new(0,0,0.15,0)
    desc.Position = UDim2.new(1,0,0.25,0)
    user.Position = UDim2.new(0.6,0,0.5,0)
end 
name.Visible = false
desc.Visible = false
user.Visible = false
f.Title.Visible = false
f:TweenSizeAndPosition(UDim2.new(0.6,0,0.08,0),UDim2.new(0.2,0,0.46,0),"In","Linear",2)
wait(2)
tl.Value = "^ And now, live! Here they are ^"
t.Visible = true
wait(4)
script.Parent.allowed.Value = true
f.Visible = false
script.Disabled = true

Heres the text in the TextLabels linking them to the StringValues in workspace. This is just the one for the desc value.

while 1+1 == 2 do
script.Parent.Text = Workspace.desc.Value
wait(.1)
end

And the script that starts it.

local passed = false
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Down:connect(function()
    passed = false
    for i,v in pairs(game.Players:GetPlayers()) do
        if v.PlayerGui.mainMessageGui.allowed.Value == true then
            v.PlayerGui.mainMessageGui.LetsGo.Disabled = false
            passed = true
        else
            passed = false
            break
        end 
    end
    if not passed then
        local msg = "This button can not be pressed at this time."
        local m = Instance.new("Message",plr.PlayerGui)
        m.Text = msg
        game:GetService("Debris"):AddItem(m,3) --Remove the messages after 3 seconds
    end
end)

Answer this question