repeat
wait()
player = game.Players:WaitForChild(script.Parent.Parent.Name)
until player ~= nil
wait(0.25)
stat = player.leaderstats.Cash -- I think this is where my error is
script.Parent.Text = stat.Value
while true do
wait()
game.ReplicatedStorage.PlayerCashInvoke:InvokeServer(stat, script.Parent)
end
And I have a new script in ServerStorage for when the RemoteFunction in invoked:
New Script
game.ReplicatedStorage.PlayerCashInvoke.OnServerInvoke = function(stat, label)
stat:GetPropertyChangedSignal("Value"):Connect(function()
label.Text = stat.Value
end)
end
Sooo… The part where I am getting errors is Line 8 in my local script. The output shows this: 21:31:01 -- leaderstats is not a valid member of Player Stack Begin Script 'Players.IAmPinleon.PlayerGui.Players.Frame.slots.IAmPinleon.Stat1.LocalScript', Line 8 Stack End
Problem is simple: A Player can NOT access ServerScriptService or ServerStorage.
If you want the Player to be able to access PlayerMoney, then you either need to always have a copy in ReplicatedStorage which reflects the current value from the one in ServerStorage, or you move the entire thing directly into ReplicatedStorage and not do any reflecting at all.
This would fail because the Client can’t access ServerStorage, if you really want to store it in ServerStorage regardless, then just reflect the Folder to ReplicatedStorage so the user can see the value.
22:52:39.523 - WaitFirstChild is not a valid member of Players
22:52:39.524 - Stack Begin
22:52:39.524 - Script 'Players.SimplyData.PlayerGui.Leaderstats', Line 2
22:52:39.525 - Stack End
You are trying to call WaitFirstChild, replace that with WaitForChild.