This is the script:
local player = game.Players.LocalPlayer while true do wait(0.1) if player.leaderstats.Level.Value >= 2 local pu= game.ReplicatedStorage.Potion:Clone() local pu2 = game.ReplicatedStorage.Potion:Clone() pu.Parent = player.Backpack pu.Parent = player.StarterGear end end
Using a while loop isn't necessary. I would suggest you use the changed event. The code to add the tool into the player's backpack is fine.
player.leaderstats.Level.Changed:Connect(function(property) If property == 'Value' and property == 2 then local pu= game.ReplicatedStorage.Potion:Clone() local pu2 = game.ReplicatedStorage.Potion:Clone() pu.Parent = player.Backpack pu.Parent = player.StarterGear end end
Try using this script. Make sure it is a local script:
local player = game.Players.LocalPlayer while true do wait(0.1) local stats = player:WaitForChild("leaderstats") if stats.Level.Value >= 2 then local pu= game.ReplicatedStorage.Potion:Clone() local pu2 = game.ReplicatedStorage.Potion:Clone() pu.Parent = player.Backpack pu.Parent = player.StarterGear end end