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

How do i get points after killing an NPC?

Asked by 3 years ago

I dont know how to do the script this is my leaderboard (it works)

rint("Cash Leaderboard Loaded")

function onPlayerEntered(newPlayer)

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

        local cash = Instance.new("IntValue")
        cash.Name = "Cash"
        cash.Value =  50
        cash.Parent = stats
        stats.Parent = newPlayer
end



game.Players.ChildAdded:connect(onPlayerEntered)

i tried puting this code in to the zombie

1 if script.Parent.Health == 0 then 2 value = value +1 just dont work

plz any1 help if you do thank you

0
Are you defining the value? ElytraIevu 26 — 3y
0
what do you mean' egopego123 0 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Heres a script For The NPC:

script.Parent.Humanoid.Died:Connect(function()
       local Players = game:GetService("Players")
       local Player = Players.LocalPlayer -- LocalPlayer is not A Service
       local leaderstats = LocalPlayer.leaderstats
       leaderstats.Cash.Value = leaderstats.Cash.Value + 1
end)

Also fix for leaderstats:

Excepted, leaderstats Parent:

function onPlayerEntered(newPlayer)
        local leaderstats = Instance.new("IntValue")            
        leaderstats.Name = "leaderstats"
        leaderstats.Parent = newPlayer

        local cash = Instance.new("IntValue")
        cash.Name = "Cash"
        cash.Value =  50
        cash.Parent = stats

game.Players.PlayerAdded:connect(onPlayerEntered)

0
You can't like that you need to find the player first. This will give Cash to the whole server. cancle5 120 — 3y
0
it dosent work the leaderstats diapear btw its first person maybe that? egopego123 0 — 3y
0
bruh i dont understand egopego123 0 — 3y
Ad
Log in to vote
0
Answered by
cancle5 120
3 years ago

Well, first you need to find the player. Try doing something like this.

local player = () -- you need to find the player with the weapon
while true do
    if script.Parent.Humanoid.Health == 0
        player.leaderstats.Cash.Value = +1
end


And then do everything else yourself cause I can't since I don't have the weapon. You need to do some script in the weapon to check who killed the npc.

0
i ummmmmmm dont understand egopego123 0 — 3y

Answer this question