Player is Nil in a Remote Event

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?

The free model is no longer being updated. Your version is out of date. Get an up-to-date copy here: Release DataStore2 v1.3.0 · Kampfkarren/Roblox · GitHub

3 Likes

I can’t, there is no link. 30 chars

1 Like

What do you mean?

You download it there.

2 Likes

But I can’t access it. 30 char

1 Like

What do you mean by “you can’t access it”

2 Likes

Like I don’t have anything that I can put it into, it just gives me the file directory when I drag it into my script.

1 Like

It is literally just a matter of downloading it then dragging it into the studio window.

2 Likes

Where do I put it? ServerScriptService?

1 Like

It would be prudent to do so.

2 Likes

And how do I put it into my script?

1 Like

You would just require(ServerScriptService.DataStore2) instead of the ID.

2 Likes

My script still doesn’t work so?

1 Like

Then you have not implemented it correctly

2 Likes

Then how do I implement it correctly? My script isn’t taking away the money when I click it like it didn’t when I made this post.

1 Like

Could you show how you are calling FireServer in your local script?

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.

Your post is confusing, is there an error?

Could we see the LocalScript that Fires the event, I believe your issue lies there.