OnServerInvoke is not a valid member of RemoteEvent.How to fix?
Asked by
6 years ago Edited 6 years ago
Tried using:
1 | game.ReplicatedStorage.tryToPurchase.OnServerInvoke:connect ( function (player, cost , spaces) |
or
1 | game.ReplicatedStorage.tryToPurchase.OnServerInvoke = function (player, cost, spaces) |
but i get the same error.
LocalScript: (GUI)
1 | local buyButton = script.Parent |
2 | local newSpaces = 1000000 |
3 | local upgradeCost = 100000000 |
5 | local function giveUpgrade() |
6 | game.ReplicatedStorage.tryToPurchase:Invoke(upgradeCost, newSpaces) |
9 | script.Parent.Activated:Connect(giveUpgrade) |
Script: (ServerScriptStorage)
01 | game.ReplicatedStorage.tryToPurchase.OnServerInvoke:connect( function (player, cost, spaces) |
03 | local playerStats = player:FindFirstChild( "leaderstats" ) |
04 | local playerGold = playerStats:FindFirstChild( "Gold" ) |
05 | local playerSpaces = playerStats:FindFirstChild( "Spaces" ) |
07 | if playerGold.Value > = upgradeCost then |
08 | playerGold.Value = playerGold.Value - cost |
09 | playerSpaces.Value = spaces |