Hi.
I’m working on a tower defense game, and so far, it’s going great! Only one problem at the moment, however: paying out players.
Each player should receive a bonus sum of cash for each wave. Because of how I set up everything, the player’s Cash value is in PlayerScripts, which works for GUIs. Unfortunately, I have a problem with getting payouts to cross between the scripts.
In my main script, the WaveComplete function pays the players the amount of cash “cash” via FireAllClients. In the LocalScript, it adds to the CashValue (the LocalScript is in StarterPlayerScripts) the “cash” argument.
The main script:
local function nextwave(cash)
game.Workspace.WaveNumber.Value += 1
game.Workspace.PayoutEvent:FireAllClients(cash)
print(cash)
end
The localscript:
game.Workspace.PlacementEvent.OnClientEvent:Connect(function(cash)
print(cash)
script.Parent.Cash.Value += cash
end)
However, while the next line prints the correct cash value in the main script, nothing comes back from the LocalScript. The cash value is not added to, and the print() function does not run. It’s like it doesn’t even receive it.
Is there something I’m missing? Am I slowly going insane from programming this game and it’s a really stupid mistake or simple solution?