Time not changing locally

  1. What do you want to achieve? Keep it simple and clear!

I want to make that when player touches part time Just for him (locally) changes. (Yes I used localscript)

  1. What is the issue? Include screenshots / videos if possible!

Time changes for everybody in server.

Time only needed to change for player on the right.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I looked on YT and forum but I haven’t found answer.

Code in localscript:


local resetLiight1 = workspace.LightChange.ResetLight1

local resetLiight2 = workspace.LightChange.ResetLight2

local resetLiight3 = workspace.LightChange.ResetLight3

local resetLiight4 = workspace.LightChange.ResetLight4


local lighting = game:GetService("Lighting")

lighting.ClockTime = 15

local Tween1 = game:GetService("TweenService"):Create(lighting, TweenInfo.new(2.5), {
	ClockTime = 3
})

local Tween2 = game:GetService("TweenService"):Create(lighting, TweenInfo.new(2.5), {
	ClockTime = 15
})

changeLight.Touched:Connect(function(hit)
	local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	
	if plr then
		Tween1:Play()
	end
end)

resetLiight1.Touched:Connect(function(hit)
	local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

	if plr then
		Tween2:Play()
	end
end)

resetLiight2.Touched:Connect(function(hit)
	local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

	if plr then
		Tween2:Play()
	end
end)

resetLiight3.Touched:Connect(function(hit)
	local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

	if plr then
		Tween2:Play()
	end
end)

resetLiight4.Touched:Connect(function(hit)
	local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)

	if plr then
		Tween2:Play()
	end
end)


You forgot to check whether the player is the one who touched the part so it’s currently detecting a touch from other players.

Just a

if plr == game:GetService("Players").LocalPlayer then

should do.

Make sure the local script is in a right spot, like StarterGui for example.

Whenever I try and change the Time in my games I always run into this problem. For some reason when I localize the ClockTime it never works.
For example:

Local ClockTime = lighting.ClockTime

That never works, I always need to call it in the function
For example:

local Tween1 = game:GetService("TweenService"):Create(lighting, TweenInfo.new(2.5), {
	Lighting.ClockTime = 3
})

NOT

local Tween1 = game:GetService("TweenService"):Create(lighting, TweenInfo.new(2.5), {
	ClockTime = 3
})

Hope this helped, probably wasn’t the solution but it’s all I can contribute.

Enable workspace.FilteringEnabled. Also, as @runiros said, you need to make sure the player is the actual local player.

It doesn’t work :frowning: Local script is inside of starter Gui

I found solution on this question on forum. Time Of Day not changing with touched part

1 Like

Just a quick note that FilteringEnabled is forced now following the removal of Experimental Mode back in Jul 25, 2018 so some of your wordings are inaccurate and only just the FE part.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.