Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What's wrong with this setup/scripts, it works once, but then the GUI removes?

So, I got a folder where I got script for the game "round": choosing map and gamemode, making teams, timers, intermission, etc. It itself works properly, but the user interface bugs. It works in studio playmode but when you go to the site and click play, the character somewhy starts at below the lobby, at that point you can see the GUI, but when your character respawns, it disappears, with no errors. I have tried setting the ResetGuiOnSpawn on and off for players, but that didn't make diffrence.

My setup has 1 server script and inside it there are modules for every gamemode. Then I also have a local script and I use remote event to write through the local script to the text label.

The activation code for the event looks like this:

function _G.fire(msg)
	RUI_event:FireAllClients(msg)
end

I use it, for instance, like this:

_G.current_board = "Map: ".. map
_G.fire(_G.current_board)

where _G.current_board is either the last string fired with the _G.fire or an empty string and map is the name of the current map.

The local script, which is stored in players backpack(also tried storing in the GUI)

local player = game.Players.LocalPlayer

local gui = player.PlayerGui:WaitForChild("GUI_MAIN") --the gui where's the text label 
local board = gui:WaitForChild("Board") --text label

local storage = game.Workspace:WaitForChild("scripts") --[[the event is stored in the same place as is the script that fires the event--]]
local event = storage:WaitForChild("RUI_event") --this is the event's name

event.OnClientEvent:connect(function(msg)
	board.Text = msg
end)

is ran on every player. It writes on the text label, based on what is sent from the server script. I have tried this many diffrent ways, but without event, I thought maybe server can't see GUIs, 'cause it complained about not finding one and before I knew the use of FireAllClients, I made invidual events for each player, they worked also on the play mode as I mentioned this did, but didn't work when you play on the site.

If you find out/know the solution, please answer this question.

Thanks,

SwaggyDuckie

4 comments

0

You're not giving us all your code, as this could never destroy the object or make it invisible. You have to have a line somewhere that says object.Visible = false or object:Destroy()

0

I definately do not remove the gui in any case or set it invisible, but I found out it disappears 'cause of I die, and I died 'cause of I had set the streaming enabled true.

0

I also discovered that currently I have removed a function-connection that defaults the gui for the player, so that if the text stays the same, when player respawns, it puts the gui to the last state of the it.

0

Though I haven't got ResetGuiOnSpawn enabled so that doesn't help.

1 answer

I found out why it wasn't working: the CharacterAdded wasn't fast enough, so the gui had not loaded once player respawned. This could've probably be fixed by testing these functions I gave, but I'm happy that it's now solved.

1 comment

0

Put [Solved] in the titel.

This discussion is preserved as it was. New answers, comments, and votes are closed.