Client Code Isn't Running

  1. What do you want to achieve? For Sky to change every time i Touch The block

  2. What is the issue? Client code isn’t running

  3. What solutions have you tried so far? Tried looking dev hub, Developer Forum Posts and else
    https://streamable.com/fgh7mg

Server:

local function onTouch(hit)
	local Humanoid = hit.Parent:FindFirstChild("Humanoid")
	if Humanoid then
		print("Fire Client Sky Remote")
		script.Parent.SkyLavaRemote:FireClient(game.Players:GetPlayerFromCharacter(Humanoid.Parent))
	end
end

local function onSnowTouch(hit)
	local Humanoid = hit.Parent:FindFirstChild("Humanoid")
	if Humanoid then
		print("Fire Client Sky Snow Remote")
		script.Parent.SkySnowRemote:FireClient(game.Players:GetPlayerFromCharacter(Humanoid.Parent))
	end
end
script.Parent.SnowSkyChange.Touched:Connect(onSnowTouch)
script.Parent.LavaSkyChange.Touched:Connect(onTouch)

Client:

local Lighting = game.Lighting
script.Parent.SkyLavaRemote.OnClientEvent:Connect(function(Player)
	if Player then
		print("Fired Lava Event In Client")
		if Lighting:FindFirstChild("Sky") then
			Lighting.Sky:Destroy()
			local Lava_Sky_Clone = script.Parent.LavaSkyChange.Sky:Clone()
			Lava_Sky_Clone.Parent = Lighting
	end
	end
end)

script.Parent.SkySnowRemote.OnClientEvent:Connect(function(player)
	if player then
		print("Fired Snow Event in Client")
		if Lighting:FindFirstChild("Sky") then
			Lighting.Sky:Destroy()
			local Snow_Sky_Clone = script.Parent.SnowSkyChange.Sky:Clone()
			Snow_Sky_Clone.Parent = Lighting
	end
	end
end)
2 Likes

Why is the client doing script.Parent, is the local script under a model in workspace? If yes, then that won’t work you need to put it under a place like StarterPlayerScripts.

1 Like

yea client is under a Folder
Снимок экрана 2023-07-26 в 16.39.08

1 Like

place it to StarterGui or StarterPlayerScripts (local script)

Alternatively, replace the LocalScript with a normal Script, use its newer RunContext property, and set that to Client instead of Legacy.

1 Like

Thanks it Worked i’ve been trying to figure it out for so long

1 Like

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