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

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

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

1 comment

0

By the way the value in the folder is called "Kills"

1 answer

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

3 comments

0

Oh ya and health isn't stored in the character itself, it's stored inside of the Humanoid

0

ill test it

0

it didnt work it gave me the error of Workspace.Zombies.Zombie.Humanoid.Script:2: attempt to index nil with 'FindFirstChild'

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