So I’m about to add this map to my game that’s primarily in nighttime mode for the most part, but this new map looks a lot better during the daytime so I wanna try and make it so that if you spawn in that map it will be daytime rather than nighttime.
Problem being though, I can’t seem to get it to work, no errors really pop up in the console so I can’t even really gauge what’s going wrong with the code.
Here is the code that’s supposed to handle the ClockTime changes:
wait(0.1)
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local Character = Player.Character --Waits for the Player to load in
local val = Character.area --Grabs the "area" value, an IntValue that changes whenever you click on a specific map to select in the character selection screen
local function onValueChanged(newValue)
if val.Value == 3 then
game.Lighting.ClockTime = 14 --If the value is set to this new map then it should make it daytime in the game for only players that entered that map
end
end
val.Changed:Connect(onValueChanged)
I didn’t know if it was like an issue with where I had the script exactly so first I had it inside of StarterCharacterScripts, but then I realized the script that I had borrowed some of the code from was originally in StarterGui so I moved it there but it only provided the same results.
I think it’s supposed to be LocalScript? Because when I changed it to be a normal script running in Client context it popped up an orange message in the console saying “Client based script in StarterGui may cause it to run multiple times, consider changing to Legacy” something along those lines.
If anybody has any advice for solving this issue then that would be greatly appreciated, thank you ! ^ ^