Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get a Spesefic Player?

****Hello,

All what I wanna do is when the NPC died the player that killed that NPC get rewarded,

Because with my current script when the NPC dies everyone gets rewarded any help plz?

local Stats = game.Players.LocalPlayer.leaderstats
local Gold = Stats.Gold

wait(1)
local hum = game.Workspace.Dummy.Dummy:FindFirstChild("Humanoid")
player = game.Players.LocalPlayer
hum.Died:Connect(function()



	print("Die")

print(player.Name.."Killed it")

print("her is your reward"..player.Name)

Gold.Value = Gold.Value + 50
if player:FindFirstChild("BruterTag") then
	local BruterTag =  player:FindFirstChild("BruterTag")

if BruterTag.Value >= 1 then
  BruterTag.Value = BruterTag.Value -1

 else if BruterTag == 0 then
	BruterTag:Destroy()
	local ir = Instance.new("BoolValue", player)
	     ir.Name = "FinishedBruterTag"
	print("BruterTag")
print("Script Finished Working")
end
end
end
end)

2 answers

Ok so i have not answered many questions on this account, so here it goes, its a honer :) So to do this i believe you, ok so first how do you kill NPC? gun or sword or punch? When answer this then ill give you answer how to do this.

3 comments

0

what? this would be better formatted as a comment

0

well, whatever

0

Punsh or Sword

I had this question a while ago. To find a specific player, you need to make a temporary tag on that player. The code below is a good way to tag the player.

local tag = human.Died:Connect(function()
--this will run if you inflicted the final hit
end) 
wait(0.1) 
tag:Disconnect()

2 comments

0

This doesnt work

0

what is wrong with it?

This discussion is preserved as it was. New answers, comments, and votes are closed.