The MouseButton1Click event does not return the player as an argument, this is why you're getting the error. You can use the LocalPlayer property of the Players service to get the current player.
local Player = game.Players.LocalPlayer
Your final code should look something like this:
local Player = game.Players.LocalPlayer
local stats = Player:WaitForChild("stats")
function Buy()
local RS = game:GetService("ReplicatedStorage")
local item = RS:WaitForChild("Ball")
local Price = 50
if (stats.Cash.Value >= Price) then
item:Clone().Parent = Player.Backpack
item:Clone().Parent = Player.StarterGear
stats.Cash.Value = stats.Cash.Value - Price
end
end
script.Parent.MouseButton1Click:connect(Buy)
2 comments
I did not use his name as stats.
ye i know i wrote it before u updated it. before u didnt show the error so i could not tell what was the error.