Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get a Spesefic Player?

Asked by 5 years ago

****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

Log in to vote
0
Answered by 5 years ago

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()
0
This doesnt work gamix912 0 — 5y
0
what is wrong with it? EliteRayGawnX2 124 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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.

0
what? this would be better formatted as a comment theking48989987 2147 — 5y
0
well, whatever CommanderCaubunsia 126 — 5y
0
Punsh or Sword gamix912 0 — 5y

Answer this question