I'm not much of a scripter so it may be something easy, but I have no idea why it won't register as a KO? Is there anything I need to change in the scripts? I'm extremely confused. Thanks for any help.
Leaderboard script:
stands = {} CTF_mode = false
function hint(text, time) local hint = Instance.new("Hint") hint.Text = text hint.Parent = game.Workspace wait(time) hint.Parent = nil end
function notify(killer, killed) local dis = (killer.Character.Torso.Position - killed.Character.Torso.Position).magnitude hint("".. killer.Name .. " has killed ".. killed.Name .." at " .. math.ceil(dis) .. " studs away.", 5) end
function onHumanoidDied(humanoid, player) local hint = player:findFirstChild("Donate") if hint ~= nil then hint.Parent = nil end local stats = player:findFirstChild("leaderstats") if stats ~= nil then local deaths = stats:findFirstChild("WOs") deaths.Value = deaths.Value + 1
-- do short dance to try and find the killer
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
handleKillCount(humanoid, player) end end
function onPlayerRespawn(property, player) -- need to connect to new humanoid if property == "Character" and player.Character ~= nil then local humanoid = player.Character.Humanoid local p = player local h = humanoid humanoid.Died:connect(function() onHumanoidDied(h, p) end ) end end
function getKillerOfHumanoidIfStillInGame(humanoid) -- returns the player object that killed this humanoid -- returns nil if the killer is no longer in the game
-- check for kill tag on humanoid - may be more than one - todo: deal with this local tag = humanoid:findFirstChild("creator")
-- find player with name on tag if tag ~= nil then
local killer = tag.Value if killer.Parent ~= nil then -- killer still in game return killer end end
return nil end
function handleKillCount(humanoid, player) local killer = getKillerOfHumanoidIfStillInGame(humanoid) if killer ~= nil then local stats = killer:findFirstChild("leaderstats") if stats ~= nil then local kills = stats:findFirstChild("KOs") local tkills = stats:findFirstChild("TKs") if killer ~= player then if killer.TeamColor ~= player.TeamColor then notify(killer, player) kills.Value = kills.Value + 1 else tkills.Value = tkills.Value + 1 end end end else hint("" ..player.Name.. " has died.", 2.5) end end
function onPlayerEntered(newPlayer)
local stats = Instance.new("IntValue") stats.Name = "leaderstats"
local kills = Instance.new("IntValue") kills.Name = "KOs"
local deaths = Instance.new("IntValue") deaths.Name = "WOs"
local tkills = Instance.new("IntValue") tkills.Name = "TKs"
kills.Parent = stats tkills.Parent = stats deaths.Parent = stats -- VERY UGLY HACK -- Will this leak threads? -- Is the problem even what I think it is (player arrived before character)? while true do if newPlayer.Character ~= nil then break end wait(3) end
local humanoid = newPlayer.Character.Humanoid humanoid.Died:connect(function() onHumanoidDied(humanoid, newPlayer) end ) -- start to listen for new humanoid newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )
stats.Parent = newPlayer end
Barrel script/s: (One)
local Barrel = script.Parent local force = Barrel:FindFirstChild("BodyForce") local touching = false local con = nil local particles = 8
function killBarrel()
Barrel.Roll.Looped = false Barrel.Roll:Stop() Barrel:remove()
end
local debris = game:GetService("Debris") Delay(5,killBarrel)
local plank = Instance.new("Part") plank.Name = "Plank" plank.Material = 512 -- wood plank.BrickColor = BrickColor.new("Reddish Brown") plank.Shape = 1 plank.formFactor = 2 plank.Size = Vector3.new(1,0.4,4) plank.BottomSurface = 0 plank.TopSurface = 0
function onTouched(part)
if touching then return end touching = true local human = part.Parent:FindFirstChild("Humanoid") if human ~= nil and Barrel.Velocity.magnitude > 20 then human:TakeDamage(25) human.Jump = true local angularVelo = Instance.new("BodyAngularVelocity") angularVelo.P = 500000 angularVelo.angularvelocity = Vector3.new(math.random(-5,5),22,math.random(-5,5)) angularVelo.maxTorque = Vector3.new(angularVelo.P,angularVelo.P,angularVelo.P) angularVelo.Parent = human.Parent.Torso debris:AddItem(angularVelo, 1) local force = Instance.new("BodyForce") force.force = Barrel.Velocity * 80 force.Parent = human.Parent.Torso debris:AddItem(force, 0.5) Barrel.GameOver:Play() con:disconnect() for i = 1, particles do local clone = plank:Clone() clone.Position = Barrel.Position clone.Parent = game.Workspace debris:AddItem(clone, 5) end killBarrel() end touching = false
end
con = Barrel.Touched:connect(onTouched)
wait(1) while true do if force.Parent ~= nil then force.force = force.force * 0.5 end wait(1) force.force = force.force * 2 wait(3) end
(Two)
local Tool = script.Parent local humanoid = nil local enabled = false
function onActivated()
if enabled then return end enabled = true humanoid = Tool.Parent:FindFirstChild("Humanoid") Tool.GripForward = Vector3.new(1,0,0) Tool.GripRight = Vector3.new(0,-1,0) Tool.GripUp = Vector3.new(0,0,1) Tool.GripPos = Vector3.new(-1,-1.5,0) Tool.Handle.Mesh.Scale = Vector3.new(1,1,1) local amountInFront = 15 local lookVector = humanoid.Parent.Torso.CFrame.lookVector local denom = math.abs(lookVector.x) + math.abs(lookVector.z) local xFactor = (lookVector.x/denom) local zFactor = (lookVector.z/denom) local posX = amountInFront * xFactor local posZ = amountInFront * zFactor local barrel = Tool.Handle:Clone() barrel.CanCollide = true barrel.Name = "Barrel" barrel.Shape = 1 barrel.formFactor = 1 barrel.Size = Vector3.new(2,3.6,2) barrel.Position = Vector3.new(posX + barrel.Position.x,humanoid.Parent.Torso.Position.y,posZ + barrel.Position.z) barrel.CFrame = CFrame.new(barrel.Position,Vector3.new(humanoid.Torso.Position.x,barrel.Position.y + 10, humanoid.Torso.Position.z)) barrel.CFrame = barrel.CFrame * CFrame.Angles(0,0,math.pi/2) local sound = Instance.new("Sound") sound.SoundId = "http://www.roblox.com/asset/?id=31033396" sound.Name = "GameOver" sound.Parent = barrel local roll = Instance.new("Sound") roll.SoundId = "http://www.roblox.com/asset/?id=31036019" roll.Name = "Roll" roll.Looped = true roll.Parent = barrel roll:Play() wait(0.6) Tool.Handle.Transparency = 1 barrel.Parent = game.Workspace barrel.Velocity = Tool.Parent.Torso.CFrame.lookVector * 80 local force = Instance.new("BodyForce") force.force = Vector3.new(0,2600,0) force.Parent = barrel local script = Tool.BarrelScript:clone() script.Parent = barrel script.Disabled = false wait(1) Tool.Handle.Transparency = 0 Tool.Handle.Mesh.Scale = Vector3.new(0.45,0.45,0.45) Tool.GripPos = Vector3.new(-0.4, -0.05, 0.11) Tool.GripUp = Vector3.new(0,1,0) Tool.GripRight = Vector3.new(0,0,1) Tool.GripForward = Vector3.new(1,0,0) Tool.GripRight = Vector3.new(0,0,1) Tool.GripUp = Vector3.new(0,1,0) Tool.GripForward = Vector3.new(1,0,0) enabled = false
end
function onEquipped() humanoid = Tool.Parent:FindFirstChild("Humanoid") end
function onUnequipped() humanoid = nil end
Tool.Activated:connect(onActivated) Tool.Equipped:connect(onEquipped) Tool.Unequipped:connect(onUnequipped)
Most likely because it does not create a creator tag inside the enemies humanoid. The way Roblox registers KO's is when someone is killed, it searches for a value inside the dead players Humanoid. The 8 Bit barrel does not make this value, thus KO's are not awarded.