Why is my script not working?

This is a local script meant to enable Colorless (A ColorCorrection with -1 saturation)

script.Parent.Touched:Connect(function(h)
	if h.Parent:IsA("Model") then
		if h.Parent:FindFirstChild("Humanoid") then
			local plr = game.Players:GetPlayerFromCharacter(h.Parent)
			if plr == game.Players.LocalPlayer then
				game.Lighting.Colorless.Enabled = true
			end
		end
	elseif h.Parent:IsA("Accessory") then
		if h.Parent.Parent:FindFirstChild("Humanoid") then
			local plr = game.Players:GetPlayerFromCharacter(h.Parent.Parent)
			if plr == game.Players.LocalPlayer then
				game.Lighting.Colorless.Enabled = true
			end
		end
	end
end)

It does nothing, like, absolutely nothing, no errors on output too.

I see script.Parent.Touched > So local scripts don’t work in the workspace.

1 Like

Oh, they don’t? So i just place the LocalScript in serverscriptservice and change the path?

First of all, instead of adding all of those if statements, I would shorten it to this:

if game.Players.LocalPlayer.Character:IsAncestorOf(h) then

end

And like @Ryuunske said, LocalScripts must be parented to a descendant of the localplayer.

If its a local script put it in starter gui or starter pack, local scripts wont work from serverscript service either.