generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Kill Spree

Previous Thread :: Next Thread 
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 05:27 PM
i was trying to make a script that whenever a user gains a KO the kill spree goes up 1 but when they die the kill spree goes to 0 this is a leaderboard scrip by the way
--------------------------------------------------------------------------------
local stats = player:findFirstChild("leaderstats")
if stats ~= nil then
local kills2 = stats:findFirstChild("Spree")
if kills.Value==kills.Value+ 1 then
kills2.Value=kills2.Value+1
if deaths.Value==deaths.Value+1 then
kills2.Value=0
end
end
------------------------------------------------------------------------------
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 05:28 PM
the spree just keeps going up when a player gets a kill but it doesnt go to 0
when you die
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
24 Jun 2014 05:32 PM
if deaths.Value==deaths.Value+1 then
is like saying
if 1==2 then


Remove that line and the end two lines later.
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 05:53 PM
i dont get it

its more like saying if
2==2
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
24 Jun 2014 05:54 PM
No it's not.

It's say if a-number== a-number+1

Do what I said and it will work :)
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 05:56 PM
then will this work?
--------------------------------
if deaths.Value+1 then
kills2.Value=0
end
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 06:01 PM
please help i am very confused because the
================================
if kills.Value==kills.Value+ 1 then
kills2.Value=kills2.Value+1

end
========================================
worked but
=============================
if deaths.Value==deaths.Value+1 then
kills2.Value=0
end
=============================
does'nt work
==========================================
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
24 Jun 2014 06:01 PM
I see what you want to do. You want to reset spree on death.

deaths.Changed:connect(function(value)
if value==0 then
kills2.Value=0
end end)
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 06:05 PM
so do i delete the death part and add your script
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 06:15 PM
do i?
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
24 Jun 2014 06:16 PM
something.Humanoid.Died:connect(function()
if Humanoid:findFirstChild("creator") then
Humanoid.creator.Value.leaderstats.Spree = Humanoid.creator.Value.leaderstats.Spree +1
end
Spree = 0
end)
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
24 Jun 2014 06:18 PM
Delete the death part (the three lines) and add mine yes
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 06:24 PM
still doesnt work
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 06:26 PM
this is the full leaderboard script Revised with smiley's script
and i wonder if you watch one piece smiley
-------------------------------------------------------
stands = {}
CTF_mode = false


function onHumanoidDied(humanoid, player)
local stats = player:findFirstChild("leaderstats")
if stats ~= nil then
local kills2 = stats:findFirstChild("Spree")
if kills.Value==kills.Value+ 1 then
kills2.Value=kills2.Value+1
deaths.Changed:connect(function(value)
if value==0 then
kills2.Value=0
end
end)
end
-- 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")
if killer ~= player then
kills.Value = kills.Value + 1
end
local kills2 = stats:findFirstChild("Spree")
if killer ~= player then
kills2.Value = kills2.Value + 1
end
end
end
end

function Send_DB_Event_Died(victim, killer)
-- killer may be nil
local killername = "no one"
if killer ~= nil then killername = killer.Name end
print("DIED EVENT: ", victim.Name, " KILLED by ", killername)

if shared["deaths"] ~= nil then
shared["deaths"](victim, killer)
print("SENT DB DEATH EVENT")
end
end

function Send_DB_Event_Kill(killer, victim)
print("KILL EVENT. ", killer.Name, " BLOXXED ", victim.Name)
if shared["kills"] ~= nil then
shared["kills"](killer, victim)
print("SENT DB KILL EVENT")
end
end



function onHumanoidDied(humanoid, player)
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)


Send_DB_Event_Died(player, killer)
handleKillCount(humanoid, player)
end
end


-----------------------------------------------


function onPlayerEntered(newPlayer)

local stats = Instance.new("IntValue")
stats.Name = "leaderstats"

local kills = Instance.new("IntValue")
kills.Name = "KOs"
kills.Value = 0

local deaths = Instance.new("IntValue")
deaths.Name = "WOs"
deaths.Value = 0

local kills2 = Instance.new("IntValue")
kills2.Name = "Spree"
kills2.Value = 0

kills.Parent = stats
deaths.Parent = stats
kills2.Parent = stats

-- Ewwww, theres a bug on my screen and if I squish it it'll get all over my screen q_q
-- 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(5)
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

game.Players.ChildAdded:connect(onPlayerEntered)

game.Workspace.ChildAdded:connect(function(item)
if item.className=="Accoutrement" or item.className=="Hat" then
local hs=script.HatScript:clone()
hs.Parent=item
hs.Disabled=false
end
end)

-----------------------------------------------------------------------------
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 06:51 PM
ANYONE? GOING TO HELP?
Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
24 Jun 2014 06:57 PM
Lad, posting that long of a script and asking us to sort through the entire thing. Really? Find the error through the Developer console, then post that section.
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
24 Jun 2014 07:12 PM
the freaking developer console didnt show a thing cause there is freaking only one player and i cant freaking kill read the posts gosh
Report Abuse
Threatboy101 is not online. Threatboy101
Joined: 27 Oct 2012
Total Posts: 874
25 Jun 2014 11:52 AM
HELP i dont know what to do
Report Abuse
tempodoa is not online. tempodoa
Joined: 06 Aug 2012
Total Posts: 251
25 Jun 2014 12:19 PM
No idea

__________________________________________

-Tempodoa was here
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image