I've been trying to get this script to work for over a day now and I'm not sure what's causing it not to work. What I'm trying to do is when the levels value in the leaderboard turns to 50 it will clone the gun into the backpack, and so far there are no errors in the output. It's located in workspace as a local script.
local plr = game.Players.LocalPlayer
local lvls = plr.leaderstats.Level.Value
local gun = game.ReplicatedStorage.RedHyperLaser
local gunClone = gun:Clone()
local gunClone.Parent = game.ServerStorage
function clonePart()
gun:Clone()
gunClone.Parent = game.ServerStorage
end
clonePart()
if lvls == 50 then
gunClone.Parent = game.Players.LocalPlayer.Backpack else
print("Error")
end

4 comments
Also I was testing this with the ROBLOX play button in studio.
Your going to have to make a while true do wait() end on 14 - 20, and a break on line 16 before else
Why are you cloning the gun on line 04, Instead you should clone in on 15-16 then change the parent
This script is so terrible I don't know how to debug it. Because everything that I'd do would be considered nit-picking but its more organized that way.