Why does this script crash my game?
Trying to make a shop script but it crashes my game when i buy it plz help
03 | local illumina = script.Parent:WaitForChild( "Illumina" ) |
04 | local units = game.Players.LocalPlayer:WaitForChild( "leaderstats" ).Units |
06 | function buySword(swordName, price, button) |
07 | if units.Value > = price then |
08 | units.Value = units.Value - price |
09 | local weapon = game.ReplicatedStorage.Weapons:FindFirstChild(swordName) |
11 | local new = weapon:Clone() |
12 | new.Parent = game.Players.LocalPlayer.Backpack |
13 | new.Parent = game.Players.LocalPlayer.StarterGear |
14 | print ( "Purchase successful! Bought " .. swordName .. " for " .. price .. " units." ) |
16 | print ( "ERROR: SWORD NOT FOUND, LINE 9 OF SCRIPT 'ShopBuy' IN MAIN > SHOPBUTTON > SHOPFRAME > SHOPBUY" ) |
19 | button.Text = "Purchased." |
21 | button.Text = swordName |
25 | illumina.MouseButton 1 Click:connect( function () buySword( "Illumina" , 1000 , illumina) end ) |