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

How can i make the game time change?

i got 2 text boxes, one for hours and one for minutes

how can i make it so the in game minutes is the same as the textbox for minutes text and in game hours is the same as the textbox for hours? local script:

script.Parent.MouseButton1Click:Connect(function()
local hour = tonumber(script.Parent.Parent.hour.Text)
local minute = tonumber(script.Parent.Parent.minutes.Text)
game.ReplicatedStorage["control time"]:FireServer(hour,minute)
end)

server script:

local minutes = 60 * 12
game.ReplicatedStorage["control time"].OnServerEvent:Connect(function(plr,hour,minute)
	minutes = minute * hour
end)
while true do
	game.Lighting:SetMinutesAfterMidnight(minutes)
	minutes = minutes + 1
	print(minutes)
	if game.Lighting.ClockTime == 12 then
		game.ServerStorage.day.Parent = game.Lighting
		game.Lighting.night.Parent = game.ServerStorage
	end
	if game.Lighting.ClockTime == 18 then
		game.Lighting.day.Parent = game.ServerStorage
		game.ServerStorage.night.Parent = game.Lighting
	end
	wait(1.5)
end

3 comments

0

What is not working exactly?

0

Whats the Output

0

its working but no the way i want it to, its pretty hard to explain whats happening so its easier if you copy the code and do the same in a test game or something

1 answer

If you create/change something in the server with a local script, it only changes that thing on the player's computer. So if you change the ControlTime to something with LocalScript, a server script will not see it. Try to make it with module script functions, here's a link if you don't know how

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