This script is saying that the player is nil even though the remote event should’ve passed over who pressed the button
local DataStore2 = require(1936396537)
local BuyObject = game:GetService("ReplicatedStorage").RemoteEvents.BuyObject
BuyObject.OnServerEvent:Connect(function(player)
local currencyStore = DataStore2("currency", player)
local ItemCost = player.PlayerGui.MainUI.ShopFrame.ItemBuyFrame.ItemPrice.ItemCost.Value
currencyStore:Increment(-ItemCost)
end)
What is the error because I assumed that remote events automatically passed over players?
You’re handling the cost of an item from the GUI side (client), this is horrible practice if they modify the value on their side and actually change the item cost.