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

Is it alright to access assets in the workspace through the local script?

This script checks whether the intermission board in question (which is in the workspace) has stopped looping through the for loop so that I can enable PlayerGUI once it's over. However, I am always hesitant to access assets on the workspace from local script fearing that the script will not work properly or it might intervene with other scripts. Of course the scripts run properly as they should, but is it okay to do that? Here is part of a script:

local PlayerGui = game:GetService("Players")
local player = PlayerGui.LocalPlayer
local Gui = player:WaitForChild("PlayerGui")
local sound = game.Workspace.OtherSounds:GetChildren()

wait(3)

while true do
	local players = game.Players:GetPlayers()
while workspace.INTERMISSIONTV.INTERMISSION.SurfaceGui.TextLabel.Text ~= "choosing map" do
	wait(3)
end

1 answer

✓ Accepted answer

Although this does work as you said this is not something I'd suggest. This seems as if it would be prone to breaking as you add more to your game.

I'd suggest using remote events. To tell all the clients in game that an Intermission has started. Or that people can now choose maps so you can then display this on a Gui for each client.

If you don't know how to do this look it up! https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

3 comments

0

I'd also suggest that if you don't want to use remotevents that you move your wait in your while loop to not be inside of the condition. As if at any point the condition is not true / false then your wait will not apply and the script will most likely time out.

0

Thank you for the reply! The wait() function is necessary in here, otherwise the game will crash. I should have mentioned that when the condition is no longer true, the server script waits for some time, which gives this specific script necessary time to continue. I already have set remote events (when the intermission ends and when I want the intermission to return back to it's original value)

0

I meant as in your using a while loop in a while loop. And only using a wait() in the embedded while loop. This means that if your 2nd while loop does not pass the condition that the wait() would not execute. You should change your code so the wait() is inside the first while loop not the 2nd.

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