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

GUI-timed script is only working in Studio, versus also working in the Player/published?

Hello! I have a time-changing script, along with GUIs that are pulled out of the ServerStorage at certain times. It works perfectly in Studio - when the clock strikes 7:20AM, (439 minutes) it displays the GUI and everything works dandy.

However, when I test it in the Player and publish it, the clock gets stuck at 7:19AM and never moves to 7:20AM. I'm not sure what could be wrong with my script, and why it would work in studio but not in the player.

Here it is -

minutesAfterMidnight = 436 -- starting time, change to 419 for 7am
sound = game.Workspace.BellSound
Door = game.Workspace.Door
Breakfast = game.ServerStorage

while true do 
	minutesAfterMidnight = minutesAfterMidnight + 1 -- don't change, 1 minute changes
	game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
	wait(3) -- how long it takes for time to pass, example change to 5 for 5 minutes, 3 to 3 minutes per hour
	
	if minutesAfterMidnight == 439 then --Notifications 7:20AM
		game.ServerStorage.Fire:FireServer("Breakfast is being served hot in the cafe in 10 minutes!", 7)
	end
end

The GUI/fire script:

local bg = script.Parent.BG
local text = bg.Text

game.ServerStorage.Fire.OnServerEvent:connect(function(player, message, seconds)
	text.Text = message
	local size = bg.Size.Y.Scale
	bg:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quad", 2, true) --Gui coming out
	wait(seconds)
	bg:TweenPosition(UDim2.new(0, 0, -size, 0), "Out", "Quad", 2, true) --Gui going in
	text.Text = ""
end)

Thanks for checking my question out!

2 comments

0

Can we see the script that happens when the fire remoteevent is being fired?

0

Sure thing! Thanks!

1 answer

✓ Accepted answer

For one, localscripts can't access game.ServerStorage, so it can't :FireServer, use ReplicatedStorage, second, Press "F9" and click Server Logs, tell us the error, on a live game, this will tell us what's wrong, post the error here, and I'll try to help further

3 comments

0

Ohh thank you for your help, I just switched it to ReplicatedStorage. The error I am getting now is "FireServer can only be called from the client". I did not know about the F9 trick, so thanks for that. This makes it much easier to look up these errors on Google!

0

Yea, for :FireServer you need a local script, change the script type to a LocalScript and it should be done!

0

Oh my goodness - it worked! You are a life saver! Thank you!

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