Its pretty weird, but what I assume is happening which doesn't make any sense is local player isn't loading even thought you pre-declared it. To fix this I moved the player declaration to inside the function.
01 | local ItemName = "Orc Blade" |
03 | local Currency = "Coins" |
08 | local ToolClone = game.Lighting:findFirstChild(ItemName):clone() |
10 | script.Parent.MouseButton 1 Click:connect( function (player) |
11 | local player = game.Players.LocalPlayer |
12 | if player.leaderstats:findFirstChild(Currency) ~ = nil then |
13 | local cash = player.leaderstats:findFirstChild(Currency) |
14 | if cash.Value > = Cost and player.Backpack:findFirstChild(ItemName) = = nil then |
15 | local ToolClone 2 = ToolClone:clone() |
16 | ToolClone 2. Parent = player.Backpack |
17 | if MinusMoney = = true then |
18 | cash.Value = cash.Value - Cost |
20 | if SaveOnDeath = = true then |
21 | local ToolClone 3 = ToolClone:clone() |
22 | ToolClone 3. Parent = player.StarterGear |