SOLVEDI have a leaderstats script, number value, and everything so the script works because I tested it with the print command, I just can't send a tool to the player's backpack and I have no idea why can anyone help me? edit: sorry for the bold
Script:
--variables
local price = script.Parent.PRICE
local name = script.Parent.Name
local tool = game.ReplicatedStorage:FindFirstChild(name)
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:connect(function()
if player.leaderstats:FindFirstChild("Cash").Value >= price.Value then --I have a leaderstats script and everything works except the end line
print("cash good yes")
player.leaderstats:FindFirstChild("Cash").Value = player.leaderstats:FindFirstChild("Cash").Value - price.Value
local clone = tool:Clone()
clone.Parent = player.Backpack --error
end
end)

6 comments
Read this: https://devforum.roblox.com/t/cloning-a-tool-and-putting-it-in-a-players-backpack/360256
I'm still confused is "game.Players.PlayerAdded:Connect(function(Player)" the same "player" as my variable?
The problem could be in the local player variable. You may have added too many "Parent"s.
No.
Do I remove the entire variable and do something else?
I fixed it^^^