Reputation: 13
I am trying to make a game on Roblox and a while ago I ran into an error, I couldn't find a fix and gave up, and I just started trying to fix it again. When I try to check if the player can afford to buy the item, I get the error Value is not a valid member of Player, here's my code from where the error is coming from
game:GetService("ReplicatedStorage"):WaitForChild("Shop"):WaitForChild("UpgradeClicks").OnServerEvent:Connect(function(player, price)
if player.leaderstats.Views.Value <= price.Value then
print("test")
end
end)
Here's the code that happens when you press the button
local RE = game:GetService("ReplicatedStorage").Shop.UpgradeClicks
local button = script.Parent
local price = script.Parent.Price
local player = game.Players.LocalPlayer
button.MouseButton1Click:Connect(function()
RE:FireServer(player, price)
end)
Upvotes: 1
Views: 2776
Reputation: 7188
When you call FireServer()
the player that calls it is automatically added as the first argument in the server callback.
So the argument list that is arriving at the server is : player, player, intValue. That's why it is saying that Player.Value isn't valid.
Change your button code to not pass in the LocalPlayer.
button.MouseButton1Click:Connect(function()
RE:FireServer(price)
end)
Upvotes: 1