Send Value Through Event And Add To Plr Leaderstats

I’m trying to multiply the player’s team score by 100, then make it send the value to the server, than add the value to their cash. The error is “attempt to perform arithmetic (add) on number and nil”. I’ve tried to transform the code a bit, and no luck. Any suggestions? I believe the value is literally 0, but I don’t know another way other than some funky ones.

local(sending value to server)

local HomeScoreValue = PlayerGui.Player.GameUI.HomeScore.Score.Value*100
		TycoonRemotes.Gametime.Gamelost:FireServer(HomeScoreValue)

server(receiving and in attempt to add value)

plr.leaderstats.Cash.Value += HomeScoreValue

This is easily exploitable
Basic Clicker Game Networking / Exploit Prevention Tutorial

I do have this similar tutorial in youtube that you can learn from and send it yourself, following it and adding tot he params of the remote event and recieivng from the param shouldnt be that difficult

-- Client

Event:FireServer(HomeScoreValue)


-- Server

Event.OnServerEvent:Connect(function(Player, HomeScoreValue)
     plr.leaderstats.Cash.Value += HomeScoreValue
    ...
end)

You shouldn’t be adding the “HomeScoreValue” on the client, this can be exploited by just calling the remote event and add a custom value (Exploiters can get infinite home score)

You should have the value already set on the server, in this case you would probably handle the GameTime on the server and you can retrieve the correct data on the server

-- Client

Remote:FireServer()


-- Server

Event.OnServerEvent:Connect(function(player)
     local gameTime = 1 -- Pre set value (Calculation through server)
     player.leaderstats.Cash.Value += gameTime * 100
end)

Also the error you’re experiencing is most likely that it didn’t find the HomeScore Value Instance.

You can use WaitForChild to yield for it.