I am trying to make it to where once you activate a click detector it tells you the Cash value within the Money folder in the player in Players, but it does not seem to print the value once clicked, why is that?
Server Script:
part = script.Parent
remote = script.Parent.RemoteEvent
part.ClickDetector.MouseClick:Connect(function(player)
remote:FireClient(player)
end)
Local Script
local remote = script.Parent.RemoteEvent
local player = game.Players.LocalPlayer
remote.OnClientEvent:Connect(function()
local Money = player.Money
local Cash = Money.Cash
print(player.Money.Cash.Value)
end)
No offenense, but this is the worst way to get a value from the player. Always remember the saying: Never trust the client.
The player could change the money and cash on the client, but not on the server.
Anyway, since when you click on the ClickDetector it passes the Player, you already have the player. Why send it through a RemoteEvent to get the player again? Just do this.
part = script.Parent
remote = script.Parent.RemoteEvent
part.ClickDetector.MouseClick:Connect(function(player)
local Money = player.Money --the player argument, and the game.players.localplayer you did in the local script are the same thing.
local Cash = Money.Cash
print(player.Money.Cash.Value)
end)
Since the argument the click detector passes is the player object, you can just search through the player there. I don’t see a point in going to a LocalScript just to get the player again.