The script does not work

here is my script, I wanted to make a system when a player enters a certain zone, then he has a sign and it says cold at the player, when the player leaves the zone, the sign went to zero and was removed, but the scripts do not work

ServerScriptService:
local EventIn = game:GetService(“StarterGui”).CRPlayer.InZone

EventIn.OnServerEvent:Connect(function(plr)
if plr.PlayerGui.Core.AnnFrame:FindFirstChild(“COLSTATUS”) then
game:GetService(“Players”).LocalPlayer:WaitForChild(“leaderstats”).ColdS.Value += 1

else

	game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").ColdS.Value += 1

	local tempcold = game:GetService("ServerStorage").COLDSTATUS:Clone()

	tempcold.Parent = plr.PlayerGui.Core.AnnFrame
end

end)

local EventOut = game:GetService(“StarterGui”).CRPlayer.OutZone

EventOut.OnServerEvent:Connect(function(plr2)

if game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").ColdS.Value >= 0 then
	game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").ColdS.Value -= 1

–[[ elseif game:GetService(“Players”).LocalPlayer:WaitForChild(“leaderstats”).ColdS.Value <= 0 and plr2.PlayerGui.Core.AnnFrame:FindFirstChild(“COLSTATUS”) then

	game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").ColdS.Value += 1

	local tempcold = game:GetService("ServerStorage").COLDSTATUS:Clone()

	tempcold.Parent = plr2.PlayerGui.Core.AnnFrame
	]]
end

end)

–plr2.PlayerGui.Core.AnnFrame:FindFirstChild(“COLSTATUS”)

StarterGUI:

local SoundRegionsWorkspace = game.Workspace:WaitForChild(“ColdestRegions”)

local Found = false

while wait(1) do

for i, v in pairs(SoundRegionsWorkspace:GetChildren()) do
	Found = false
	local region = Region3.new(v.Position - (v.Size/2),v.Position + (v.Size/2))
	
	local parts = game.Workspace:FindPartsInRegion3WithWhiteList(region, game.Players.LocalPlayer.Character:GetDescendants())
	
	for _, part in pairs(parts) do
		if part:FindFirstAncestor(game.Players.LocalPlayer.Name) then
			print("player was found")
			Found = true
			
			break
		else
			Found = false
			
			print("player was not found in region")
		end
	end

if Found == true then
		script.InZone:FireServer()
	elseif Found == false then
		
		script.OutZone:FireServer()
		
	end
end

end

image

Any errors or warnings in the output?

no have, i can’t find them or console just now writing them.

Have you tried using print() to help find the issue?

1 Like

I dont know if your ui is called like that but in your server script it says:
if plr.PlayerGui.Core.AnnFrame:FindFirstChild(“COLSTATUS”) then
And in other parts of the scripts your wrote COLDSTATUS?
Maybe its because you wrote something wrong and the script cant find it and wont continue

If you wrote everything correct try to use print() as allene50 said above
Use it after each if statement where you use FindFirstChild()

Example:

if gui:FindFirstChild(...) then
print("1")
if gui:FindFirstChild(...) then
print("2")
end
end

This should help you finding the part where it stops working

1 Like

Instances from ServerStorage/ServerScriptService are not available on the client.

image

Your remote event should be located in ReplicatedStorage for the most efficiency. If you must have it in the gui for whatever reason, use the one in PlayerGui, not StarterGui.

2 Likes

now i try change colsstatus to COLDSTATUS

oh wait maybe you helped me i need to test and rescript it

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