~~~~~~~~~~~~~~~~~Player=script.Parent.Parent.Parent.Parent.Parent
script.Parent.Text=tostring(script.Parent.ItemName.Value)..": "..tonumber(script.Parent.Cost.Value).." "..tostring(script.Parent.Currency.Value)
script.Parent.MouseButton1Click:connect(function()
if Player:findFirstChild("leaderstats") then
if Player.leaderstats[script.Parent.Currency.Value].Value>=tonumber(script.Parent.Cost.Value) then
Player.leaderstats[script.Parent.Currency.Value].Value=Player.leaderstats[script.Parent.Currency.Value].Value-tonumber(script.Parent.Cost.Value)
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=Player.Backpack
game.Lighting[script.Parent.ItemName.Value]:Clone().Parent=Player.StarterGear
end
end
end)
~~~~~~~
~~~~~~~~~~
I'm guessing this is in a Gui Text Button?
It may be easier if you use a LocalScript for this sort of thing
--LocalScript-- Player = game.Players.LocalPlayer WeaponList = game.ReplicatedStorage.Weapons -- Re-path if need. Button = script.Parent repeat wait() until Player:FindFirstChild("leaderstats") cash = leaderstats.Cash --Player's Cash Button.MouseButton1Up:connect(function() if cash.Value >= Button.Cost.Value then for _,v in pairs(WeaponList:GetChildren()) do v:Clone().Parent = Player.Backpack end end end)
Also, your code goes between
"~~~~~~~~~~~"
code
"~~~~~~~~~~~"