Edit: I also noticed that you’re using LocalPlayer in a server script. This will be nil, because LocalPlayer is the pllayer that LocalScripts run for, and you have a player parameter in OnServerEvent, so use that instead of LocalPlayer.
As GalaxyGourmet said you’re going to still run into issues due to that local player. You need to instead change that to the Player you have passed via the remote in the function.
local upgrades = game.Players.LocalPlayer.PlayerScripts:WaitForChild('UpgradesIntValue')
would become
local upgrades = game.Players:FindFirstChild(player.Name).PlayerScripts:WaitForChild('UpgradesIntValue')
You aren’t suppose to localise the function. The Event is an actual Remote Event where you define its location.
Example:
local Event = game.ReplicatedStorage.RemoteEvent
Event.OnServerEvent:Connect(function(player)
–Do something here
end)