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

expected string, got nil?

wait(1)
LoadCoins = game.ReplicatedStorage.Coins:Clone()
LoadCoins.Parent = game.Workspace
local player = game.Players.LocalPlayer
h = game.ReplicatedStorage.ScreenGui:Clone()
h.Parent = player.PlayerGui
local CoinAmount = h.Frame.TextLabel

while true do
	wait()
	CoinAmount.Text = _G.Coins
end

It fails at line 11 for the reason stated in the title, the script is located in starterplayerscripts and the game has filteringenabled. _G.Coins is a value that is at default set to 0. It works just fine in studio.

2 answers

I've noticed a lot of problems using _G. functions recently. I don't know if it's a bug or if Roblox is trying to deprecate it

Whichever it is I recommend using Bindable Events to send data from scripts located client-side

I can't make a script for you to use that as I don't know how you have everything else set up, but I hope this solves your problem!

_G does not replicate between server and client. If you have defined _G.Coins on the server (ex in a leaderboard or datastore script), the client won't have access to that information. Look into RemoteEvents instead.

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