Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i make the game time change?

Asked by 4 years ago

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
0
What is not working exactly? starmaq 1290 — 4y
0
Whats the Output sturdy2004 110 — 4y
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 Gameplayer365247v2 1055 — 4y

1 answer

Log in to vote
0
Answered by
WoTrox 345 Moderation Voter
4 years ago

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

Ad

Answer this question