Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

FilteringEnabled Code Errors When It's Correct???

Here is the code, it does not work and leaves this error: "Workspace.Script:7: attempt to index local 'Label' (a nil value)". How so is 'Label' nil?

--Server Script
RE = Instance.new("RemoteEvent")
RE.Name = "GuiChangeEvent"
RE.Parent = game.Workspace.Code.Events

RE.OnServerEvent:connect(function(Player, Label, Cash)
	print(Cash)
	Label.Text = "Coins: "..Cash
end)
--Local Script
Player = game.Players.LocalPlayer
Gui = Player.PlayerGui
RE = game.Workspace.Code.Events:WaitForChild("GuiChangeEvent")
Label = Gui:WaitForChild("CashLabelGui"):WaitForChild("Display")
Stats = Player:WaitForChild("Leaderboard"):WaitForChild("Currency")

Stats.Changed:connect(function(Change)
	if Label then		
		RE:FireServer(Label, Stats.Value)
	end
end)

halp pl0x

1 answer

✓ Accepted answer

The server should not and cannot manipulate GUIs.

There is absolutely no reason for this to involve a Script at all.

Your code should just be

Stats.Changed:Connect(function()
	Label.Text = "Coins: " .. Stats.Value
end

This discussion is preserved as it was. New answers, comments, and votes are closed.