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 » Scripters
Home Search
 

Re: Exp on kill of an npc

Previous Thread :: Next Thread 
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 10:32 AM
i dont understand why this not work

local Humanoid = script.Parent.Humanoid

function OnKill()
local tag = Humanoid:findFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local leaderstats = tag.Value:findFirstChild("leaderstats")
if leaderstats ~= nil then
leaderstats.exp.Value = leaderstats.exp.Value + 1
wait(0.1)
script:remove()
end
end
end
end

Humanoid.Died:connect(OnKill())


Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 10:48 AM
BUMP


Report Abuse
memorycode is not online. memorycode
Joined: 24 Sep 2011
Total Posts: 3322
11 Dec 2016 10:53 AM
:Connect(OnKill)

not :connect(OnKill())


i'm not any more should not the panda and?
Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 11:05 AM
didnt work, and wouldnt it be a lowercase 'c' in ":connect"


Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 11:18 AM
BUMP


Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 11:49 AM
BUMP help me pls








Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
11 Dec 2016 11:59 AM
local players = game.Players
local pp = game.Players:GetPlayers()

for i = 1,#pp do
local humanoid = pp[i].Character:WaitForChild("Humanoid")
humanoid.Died:Connect(function(deadplayer)
local tag = humanoid:FindFirstChild("creator")
if tag ~= nil and tag.Value ~= nil and tag.Value.Parent == players then
if deadplayer.Parent ~= players then
local killer = tag.Value
local leaderstats = killer:FinidFirstChild("leaderstats")
if leaderstats ~= nil then
local expvalue = leaderstats:FindFirstChild("Exp")
expvalue.Value = expvalue + 1
end
end
end)
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
11 Dec 2016 12:00 PM
local players = game.Players
local pp = game.Players:GetPlayers()

for i = 1,#pp do
local humanoid = pp[i].Character:WaitForChild("Humanoid")
humanoid.Died:Connect(function(deadplayer)
local tag = humanoid:FindFirstChild("creator")
if tag ~= nil and tag.Value ~= nil and tag.Value.Parent == players then
if deadplayer.Parent ~= players then
local killer = tag.Value
local leaderstats = killer:FinidFirstChild("leaderstats")
if leaderstats ~= nil then
local expvalue = leaderstats:FindFirstChild("Exp")
expvalue.Value = expvalue + 1
end
end
end
end
end)
Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 12:06 PM
is the humanoid defined as the plr's humanoid or the npc(<-- want tht)





Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 12:09 PM
BUMP


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
11 Dec 2016 12:20 PM
it is defined as the player's humanoid
Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 12:23 PM
the title says 'npc' ; would it work if i define the npc's humanoid instead


Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
11 Dec 2016 12:24 PM
there is a part in the script that checks ### ## what was killed. "if deadplayer.Parent ~= players then" this checks if the person who died parent is not "game.Players" or "Players" this will return true if the person who died's parent is not in "Players",it will return false if it is in "Players"
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
11 Dec 2016 12:25 PM
omg srsly roblox :l
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
11 Dec 2016 12:25 PM
oh.... ill fix it
Report Abuse
Gomlsauresrex is not online. Gomlsauresrex
Joined: 25 Mar 2016
Total Posts: 3588
11 Dec 2016 12:26 PM
well..

Yes it would
Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 12:34 PM
both your previous piece of code and the one defining humanoid didn't work



Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 12:37 PM
does anyone know why this isnt working:

local Humanoid = script.Parent.Humanoid

function OnKill()
local tag = Humanoid:findFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local leaderstats = tag.Value:findFirstChild("leaderstats")
if leaderstats ~= nil then
leaderstats.exp.Value = leaderstats.exp.Value + 1
wait(0.1)
script:remove()
end
end
end
end

Humanoid.Died:connect(OnKill)

or any more solutions


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
11 Dec 2016 12:43 PM
I don't think NPCs are tagged when they are hit with a weapon...
Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 12:47 PM
n how would i go about giving a player experience when killing an npc





Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
11 Dec 2016 12:48 PM
that depends on how your weapon script works.
Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
11 Dec 2016 12:56 PM
did you get an error on output?


Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 01:03 PM
hing came up there (no errors)


Report Abuse
blackmuawiyah is not online. blackmuawiyah
Joined: 10 Sep 2011
Total Posts: 263
11 Dec 2016 01:12 PM
nothing came up





Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
11 Dec 2016 01:37 PM
then it's not an error. the problem is probably that if statements, why don't you add prints in each block to check if the script goes through or not?


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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