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

Problems making a script from ServerScriptService change the text of a TextLabel in FE?

This is an old script of mine and it was created before FE was a thing. I'm really not sure how to fix it. Can someone help me?

Script:

while true do
game.Lighting.TimeOfDay = "1:00:00"
Game.Lighting.Brightness = 0
Game.Lighting.Ambient = Color3.new( .0,.0,.0 )
waittime = (0.5)
 
for i,v in pairs(game.Players:GetChildren())do
		v.PlayerGui.TimeGui.TimeLabel.Text = "1:00 AM" end
game.Lighting.TimeOfDay = "1:00:00"
wait(waittime)
for i,v in pairs(game.Players:GetChildren())do
		v.PlayerGui.TimeGui.TimeLabel.Text = "1:15 AM" end
game.Lighting.TimeOfDay = "1:15:00"
wait(waittime)
for i,v in pairs(game.Players:GetChildren())do
		v.PlayerGui.TimeGui.TimeLabel.Text = "1:30 AM" end
game.Lighting.TimeOfDay = "1:30:00"
wait(waittime)
end

1 answer

✓ Accepted answer

FE prevents scripts running on the server from accessing player GUIs.

It may be better to create a local script that uses .Changed to update whenever game.Lighting.TimeOfDay changes.

I have provided an example:

-- inside a LocalScript, inside TimeGui
game.Lighting.Changed:Connect(function(property)
	if property == "TimeOfDay" then
		-- add AM/PM line here, otherwise...
		script.Parent.TimeLabel.Text = game.Lighting.TimeOfDay
	end
end)

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