local leaderstats = Instance.new("Folder")
leaderstats.Name = 'leaderstats'
leaderstats.Parent = player
local kills = Instance.new("IntValue")
kills.Value = 0
kills.Name = 'Kills'
kills.Parent = leaderstats
local streak = Instance.new('IntValue')
streak.Value = 0
streak.Name = 'Streak'
streak.Parent = player
local deaths = Instance.new('IntValue')
deaths.Value = 0
deaths.Name = 'Deaths'
deaths.Parent = leaderstats
local cash = Instance.new('IntValue')
cash.Value = 100
cash.Name = 'Cash'
cash.Parent = leaderstats
local killer = Instance.new('StringValue')
killer.Name = 'Killer'
killer.Parent = player
local instaKill = Instance.new('BoolValue')
instaKill.Name = 'InstaKill'
instaKill.Value = false
instaKill.Parent = player
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
--Death Tracker
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value + 1
player.Streak.Value = 0
local killerTag = game.Players:FindFirstChild(player.Killer.Value)
if killerTag then
killerTag.leaderstats.Kills.Value = killerTag.leaderstats.Kills.Value + 1
killerTag.leaderstats.Cash.Value = killerTag.leaderstats.Cash.Value + 50
killerTag.Streak.Value = killerTag.Streak.Value + 1
if killerTag ~= 1 then
game.ServerStorage.SniperTestingGun:Clone().Parent = player:WaitForChild("Backpack")
game.ServerStorage.SniperTestingGun:Clone().Parent = player:WaitForChild("StarterGear")
end
end
end)
end)
end)
Does the leaderboard add the other leaderstats and not the kills alone?
Can I see the code where the Killer value is updated?
--Object and Sound Variable
local gun = script.Parent
local gun_shot = gun:WaitForChild("Handle") ["Gun Shot"]
local empty_sound = gun:WaitForChild("Handle") ["Empty Gun Sound"]
local reload_sound = gun:WaitForChild("Handle") ["Reload Sound"]
local player = game.Players.LocalPlayer
local clipSize = gun:WaitForChild('Ammo').Value
local ammo = gun:WaitForChild('Ammo')
--UserInputService Setup
local userInput = game:GetService('UserInputService')
--Mouse Icon
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = 'rbxassetid://117431027'
--Remote Event Setup
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild('ShotEvent')
--Update ammo function
local function update_ammo()
player.PlayerGui.Sprint.Ammo.Text = "Ammo: ".. tostring(ammo.Value)
end
--Checks if Mouse is clicked/ if equipped
gun.Equipped:Connect(function(mouse)
player.PlayerGui.ScreenGui.Ammo.Visible = true
player.PlayerGui.ScreenGui.Ammo.Text = "Ammo: ".. tostring(ammo.Value)
mouse.Button1Down:Connect(function()
if gun.Ammo.Value > 0 then
remoteEvent:FireServer(gun.Handle.Position, gun.Handle.Orientation, mouse.Hit.p)
gun_shot:Play()
wait(0.25)
gun_shot:Play()
gun.Ammo.Value = gun.Ammo.Value - 2
if gun.Ammo.Value < 0 then
wait(3)
gun.Ammo.Value = 30
else
empty_sound:Play()
end
end
end)
--If I want to change zoom in back
mouse.Button2Down:Connect(function()
local camera = game.Workspace.CurrentCamera
camera.FieldOfView = 50
end)
mouse.Button2Up:Connect(function()
local camera = game.Workspace.CurrentCamera
camera.FieldOfView = 75
end)
end)
--Unequipped gun
gun.Unequipped:Connect(function()
player.PlayerGui.ScreenGui.Ammo.Visible = false
end)
--Checks if the letter R is pressed to reload
userInput.InputBegan:Connect(function(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
local keycode = input.KeyCode
if keycode == Enum.KeyCode.R then
if gun.Ammo.Value < clipSize and gun.MaxAmmo.Value > 0 then --clipSize is ammo value
reload_sound:Play()
reload_sound.Ended:Wait()
if gun.MaxAmmo.Value - (clipSize - gun.Ammo.Value) >= 0 then
gun.MaxAmmo.Value = gun.MaxAmmo.Value - (clipSize - gun.Ammo.Value)
gun.Ammo.Value = clipSize
else
gun.Ammo.Value = gun.Ammo.Value + gun.MaxAmmo.Value
gun.MaxAmmo.Value = 0
player.PlayerGui.Sprint.Ammo.Text = "Ammo: ".. tostring(ammo.Value)
end
end
end
end
end
end)
--Update ammo GUI
ammo.Changed:Connect(function(update_ammo)
gun.MaxAmmo.Value = gun.Ammo.Value + 10
player.PlayerGui.ScreenGui.Ammo.Text = "Ammo: ".. tostring(ammo.Value)
end)
Wait no that’s the wrong script
local bullet = script.Parent
local headshot_sound = game.Workspace.HEADSHOT
local function player_check(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
local shooter = game.Players:FindFirstChild(bullet.Attacker.Value)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
local killerTag = game.Players:FindFirstChild(player.Killer.Value)
if humanoid and otherPart.Parent.Name ~= bullet.Attacker.Value then
if player.TeamColor ~= shooter.TeamColor and game.Players:GetPlayerFromCharacter(otherPart.Parent).TeamColor ~= shooter.TeamColor then
humanoid:TakeDamage(0)
if shooter.InstaKill.Value == true then
humanoid:TakeDamage(999)
else
if otherPart.Name == 'Head' then
humanoid:TakeDamage(100)
headshot_sound:Play()
elseif otherPart.Name == "HumanoidRootPart" then
humanoid:TakeDamage(30)
else
humanoid:TakeDamage(15)
end
end
else
if player then
local tag = player:FindFirstChild('Killer')
if tag then
tag.Value = bullet.Attacker.Value
end
end
end
end
bullet:Destroy()
end
bullet.Touched:Connect(player_check)
This is a server script, right?
Server storage. It is cloned to the bullet.
@DevCoolPool Your player variable is the name of the character, not the actual object, or even a property of the player. otherpart.Parent is the character, not the player. OtherPart.Parent.Name is the name of the character object in workspcae. So your code here is looking for the killer value inside the Name property of the character, which returns nil.
What do you mean. Can you tell me what to do.
What line would I change and what would I put? What am I supposed to be getting?
Are you saying that there is a problem getting the player/killer? What do you mean, how would I get the play then?
I just tried this
local player = game.Players:FindFirstChild(humanoid.Parent.Name)
I think you can just do local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)