Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

expected string, got nil?

Asked by 6 years ago
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

Log in to vote
0
Answered by 6 years ago

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!

Ad
Log in to vote
0
Answered by 6 years ago

_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.

Answer this question