I already have a simple script done that would track down kills and give weapons. The problem is that I don't know how to specific if a player has an amount of kills. I want the player to have 1 kill before getting the GLOCK 17. And yes, I already have my leaderboard setup.
local player = game:GetService("Players").LocalPlayer player.leaderstats.Kills.Value = 1 --what to do with this line? game.ServerStorage.Guns["GLOCK 17"]:Clone().Parent = player.Backpack print("script success")
EDIT: I made a new script based off of CodeOverload's suggestions but I don't know why it's not working. Note that the game I am making runs like this: Someone kills a person, they gain a better weapon. I grabbed a quick death and kills script free model that works.
local player = game:GetService("Players").LocalPlayer if player.leaderstats.Kills.Value == 1 then --tracks the player's kills game.ServerStorage.Guns["USP-S"]:Clone().Parent = player.Backpack --gives gun print("usp-s") --just to make sure you get the gun if player.leaderstats.Kills.Value == 2 then --tracks player's kills player.Backpack["USP-S"]:Destroy() --destroys previous gun game.ServerStorage.Guns["Beretta"]:Clone().Parent = player.Backpack --gives gun print("beretta") --just to make sure you get the gun end end
I think you forgot the function, with only:
local player = game:GetService("Players").LocalPlayer if player.leaderstats.Kills.Value == 1 then game.ServerStorage.Guns["USP-S"]:Clone().Parent = player.Backpack print("usp-s") if player.leaderstats.Kills.Value == 2 then player.Backpack["USP-S"]:Destroy() game.ServerStorage.Guns["Beretta"]:Clone().Parent = player.Backpack print("beretta") end end
it only runs one time. If I was you I'd use this script, it will not be flawless but this will do:
function changeweapon () local player = script.Parent.Parent local kills= player.leaderstats.Kills if kills.Value == 1 then game.ServerStorage.Guns["USP-S"]:Clone().Parent = player.Backpack print("usp-s") end if kills.Value == 2 then player.Backpack["USP-S"]:Destroy() game.ServerStorage.Guns["Beretta"]:Clone().Parent = player.Backpack print("beretta") end end script.Parent.Parent.leaderstats.Kills.Changed:connect(changeweapon) wait(.2) changeweapon()
Place the script above in a local script and put the local script in game.StarterPlayer.StarterPlayerScripts