[REPOST] Having problem with client when the game is multiplayer

Well, I’ve posted this about my game. It has a mechanic that, when you jump, changes the time (from day to night and vice versa). If you try it on your own, it works perfectly, only if it’s solo, I want to make it multiplayer but I’m having problems with it.

When the game is multiplayer, there are times that the time is changed without you jumping. I don’t have any ideas on how I can fix it.

Below here, it has a replica of how the mechanic works if you want to try to redo it and fix anything or other.
mainJumpScript.rbxl (53.7 KB)

But if you don’t want to do this, follow these steps:

Step by step of how I did the mechanic.
  1. Added parts inside a folder named “ObbyParts” named “Day” and “Night”. It can be only 1 of each to make the example.
  2. Add a LocalScript on StarterPlayerScripts
  3. Add this line of code:
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Lighting = game.Lighting

local ChangeTime = true

local player = Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")
task.wait(3)
local TouchGui = PlayerGui:FindFirstChild("TouchGui")

local function detectTime(parts)
	if not ChangeTime then
		for _, part in ipairs(parts) do
			if part.Name == "Day" then
				part.Transparency = 0
				part.CanCollide = true
			end
			if part.Name == "Night" then
				part.Transparency = 0.5
				part.CanCollide = false
			end
		end
	else
		for _, part in ipairs(parts) do
			if part.Name == "Day" then
				part.Transparency = 0.5
				part.CanCollide = false
			end
			if part.Name == "Night" then
				part.Transparency = 0
				part.CanCollide = true
			end
		end
	end
end

local debounce = false

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Space then 
		if not debounce then
			debounce = true
		end
		if debounce then
			local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)
			
			if Lighting.ClockTime == 12 then
				ChangeTime = true
				local targetTime = 0
				local tween = TweenService:Create(Lighting, tweenInfo, {ClockTime = targetTime})
				tween:Play()
				tween.Completed:Wait()
			else
				ChangeTime = false
				local targetTime = 12
				local tween = TweenService:Create(Lighting, tweenInfo, {ClockTime = targetTime})
				tween:Play()
				tween.Completed:Wait()
			end
		end
		debounce = false
	end
end)

if TouchGui ~= nil then
	local TouchControlFrame = TouchGui:WaitForChild("TouchControlFrame")
	local JumpButton = TouchControlFrame:WaitForChild("JumpButton")
	if JumpButton and JumpButton:IsA("ImageButton") then
		JumpButton.MouseButton1Click:Connect(function()
			if not debounce then
				debounce = true
			end
			if debounce then
				local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear)

				if Lighting.ClockTime == 12 then
					ChangeTime = true
					local targetTime = 0
					local tween = TweenService:Create(Lighting, tweenInfo, {ClockTime = targetTime})
					tween:Play()
					tween.Completed:Wait()
				else
					ChangeTime = false
					local targetTime = 12
					local tween = TweenService:Create(Lighting, tweenInfo, {ClockTime = targetTime})
					tween:Play()
					tween.Completed:Wait()
				end
			end
			debounce = false
		end)
	end
end

detectTime(workspace.ObbyParts:GetDescendants())

Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	detectTime(workspace.ObbyParts:GetDescendants())
end)
  1. And that’s all!

I’ve tried some options like changing the ClockTime to an IntValue by the same name, but besides not having worked, it broke the mobile function. I don’t know what can I do to fix it.