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

SurfaceGUI Not selecting isn't selected. How do I fix?

Asked by 4 years ago

Hello I have a surface gui that I'm trying to make activate a screengui with custom text to everyone on the server.

I have this so far

function leftClick()
game.StarterGui.EASGui.Frame.ALERT.Text = script.script.Parent.Parent.TextBox.Text 
        script.Parent.Parent.TextBox.Text = ""
        wait(3)
game.StarterGui.EASGui.Frame.Sound.Playing = true
game.StarterGui.EASGui.Enabled = true
wait(30)
game.StarterGui.EASGui.Enabled = false

end

script.Parent.MouseButton1Click:Connect(leftClick)

for the localscript under my textbutton

BTW: Keep in mind that I'm trying to activate the GUI for the ENTIRE server.

1 answer

Log in to vote
0
Answered by 4 years ago

To begin, you can't use a LocalScript to change everyone's screen without using a RemoteEvent.

Second, if you change "StarterGui" it won't have any effect, it has to be the PlayerGui, which is a child of each individual player.


To start, put a RemoteEvent in ReplicatedStorage and name it "AlertEvent".

Next, inside your button put a LocalScript and write this.

local event = game:GetService("ReplicatedStorage"):WaitForChild("AlertEvent")

script.Parent.MouseButton1Click:Connect(function()
    local textToSend = script.Parent.Parent.Parent.TextBox
    event:FireServer(textToSend.Text)
end)

This will send arguments to the server, where we will change everyones screen, the first argument will always be the player firing the event, and then any arguments afterwards. For this example, our only argument will be the text that we want to alert.

After that, put a ServerScript inside of ServerScriptService and write this.

local event = game:GetService("ReplicatedStorage"):WaitForChild("AlertEvent")

event.OnServerEvent:Connect(function(plr,text)
    for _,player in pairs(game:GetService("Players"):GetChildren()) do
        player:WaitForChild("PlayerGui"):FindFirstChild("EASGui").Frame.ALERT.Text = text
        wait(3)
        player:WaitForChild("PlayerGui"):FindFirstChild("EASGui").Frame.Sound:Play()
        player:WaitForChild("PlayerGui"):FindFirstChild("EASGui").Enabled = true
        wait(30)
        player:WaitForChild("PlayerGui"):FindFirstChild("EASGui").Enabled = false
    end
end)

This will receive the player who fired the event, and the text we want to change. It will also loop through every player's gui and change the text, play the sound, make it visible, wait 30 seconds, and then not make it visible.

Hope this helped!

If this worked for you, let me know by selecting this as the answer!

If it didn't work, comment down below what went wrong and I'll try to help.

0
Well, I forgot to say this in my original question but my textbox doesn't select when I try to type in it. It's not selecting when I click it. Text Editable is enabled verbxtim 2 — 4y
0
Is it a TextBox or a TextButton? If it's a TextButton, that's the problem. If it's a TextBox, try re-inserting it into the previous place. killerbrenden 1537 — 4y
0
Okay. verbxtim 2 — 4y
0
Actually, I don't need this GUI anymore anyways. Thanks for you help. verbxtim 2 — 4y
0
No problem! killerbrenden 1537 — 4y
Ad

Answer this question