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

Im trying to make it so you get a kill when you kill a zombie but it doesnt work?

Asked by 2 years ago

I put the script in a Zombie that gets cloned into workspace its in a regular script I also tried it in a local script but it didn't work does anyone know whats wrong?

local player = game.Players.LocalPlayer
local leaderstats = player:FindFirstChild("leaderstats")
local kill = leaderstats.Kills.Value

if script.Parent.Health == 0 then do
        kill.Value = kill.Value + 1
    end
end
0
By the way the value in the folder is called "Kills" TheForgottenScript 4 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

First you called value 2 times, and 2nd you can't use .value inside of a value and 3rd your using "then do" instead of using then, and also 4th you have to use a local script inside of the player to use "LocalPlayer" so you'll have to set up remoteevent to change the value, so it'll have to be like this:

local player = game.Players.LocalPlayer
local leaderstats = player:FindFirstChild("leaderstats")
local kill = leaderstats.Kills

if script.Parent.Health == 0 then
              kill.Value = kill.Value + 1
       end
end
0
Oh ya and health isn't stored in the character itself, it's stored inside of the Humanoid dizzyjamison08 30 — 2y
0
ill test it TheForgottenScript 4 — 2y
0
it didnt work it gave me the error of Workspace.Zombies.Zombie.Humanoid.Script:2: attempt to index nil with 'FindFirstChild' TheForgottenScript 4 — 2y
Ad

Answer this question