Hi, I’m making this server script, but I’m not sure how to define player. I have a script similar to this but I don’t know how I defined player.
Old Script With Player Defined
game.ReplicatedStorage.CheckSale.OnServerInvoke = (function(player,item)--Responds to the remote function request
local shopItems = game:GetService("ServerStorage"):WaitForChild("ShopItems")--Defines the items in ServerStorage
local price = shopItems[item].Gold.Value--Defines the price of the item
if player.leaderstats.Gold.Value >= price then--Check to see if the player has enough money
player.leaderstats.Gold.Value = player.leaderstats.Gold.Value - price--Subtracts the price
local gear = shopItems[item]:FindFirstChildOfClass("Tool"):Clone()--Clones the item they bought
gear.Parent = player.Backpack--Put the clone in their backpack
return true
else
return false
end
end)
Script With Player Not Defined
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local upgrades = game.Players.LocalPlayer.PlayerScripts:WaitForChild('UpgradesIntValue')
local increase = 1.5
local price = upgrades.Value*increase
if player.leaderstats.Elixir.Value >= price then
player.leaderstats.Elixir.Value = player.leaderstats.Elixir.Value - price
upgrades.Value = upgrades.Value + 1 --- This is supposed to change the value of an IntValue am I doing this right?
return true
else
return false
end