This script works, if I put the tool into workspace. But when I try to but it into Backpack, I think the problem is how the player is stored, can someone tell me a better solution.
local player = game.Players
Cash = script.Parent.Parent.Parent.Parent.Parent.RealMoney
function onClick()
if Cash.Value >= 10 then
Cash.Value = Cash.Value - 10
local RockLaunch = game.Lighting.Spas12:clone()
RockLaunch.Parent = script.Parent.Parent.Parent.Parent.Parent.StarterGear
local RockLaunch = game.Lighting.Spas12:clone()
RockLaunch.Parent = player.Backpack
end
end
script.Parent.MouseButton1Click:connect(onClick)

4 comments
try putting the variable under the function
So like this script.Parent.MouseButton1Click:connect(player)
Nope put the cash variable under the function onClick() if needed then add local Cash at line2
the cash isn't the problem its the player