The zombies humanoid is named Zombie so you cant shoot teammates so do I still have to do script.Parent.Zombie.Humanoid.Died
You shouldn’t be renaming the Humanoid of the Zombie, that may be the problem.
To check if a character is an NPC or a player, just do this instead:
local plr = game.Players:FindFirstChild(character.Name)
if plr then -- It is a player
else -- It's not
What all do I change to switch to something this style:
if plr then -- It is a player
else -- It's not
- Don’t rename your zombie’s Humanoid.
- Make sure you have a script in your guns that tags the zombies with an ObjectValue
- Make sure your Kill/Money script is a Script not a LocalScript(Local Scripts can’t change values)
Yeah I have learned that local scripts don’t work. (the hard way)
I’ll try making a simple demo in Roblox Studio.
So do I do something like this
local plr = game.Players:FindFirstChild(character.Name)
if plr then
plr.Humanoid.Health = plr.Humanoid.Health - 0
else
Hit.Parent.Humanoid.Health = Hit.Parent.Humanoid.Health - 10
Put this in a script, and use this function when you detect that the gun has hit something.
function OnHit(plr, hit)
--Plr is the plr who shot the gun
if hit.Parent then
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
local hitPlr = game.Players:FindFirstChild(hit.Parent.Name)
if not hitPlr then -- If it's not a player
--Do Damage
hum:TakeDamage(10)
-- Add a tag to the zombie
if hum.Health <= 0 then --Player has killed the zombie because Health is lower than 0
local tag = Instance.new("ObjectValue",hit.Parent)
tag.Name = "creator"
tag.Value = plr -- Player who fired the gun
end
end
--If it is a player, do nothing
end
end
end
where do I put the script at in the gun or workspace or serverscriptservice
In the gun, with your hit detection.
How are you checking for hits. Do you use bullet.Touched or raycasting or some other method?
I normally just do raycasting for that stuff
Ok, so then put this with your raycasting script.
local hit, position = workspace:FindPartOnRayWithIgnoreList(ray, ignore)
if hit then
OnHit(plr,hit)
end
Why are the zombies no longer attacking me after I changed the humanoid name to Humanoid. Also Do I do the same script or a melee weapon.
Are you using the Roblox zombie?
No I am using a custom one made for me by a friend for this
Since you’ve used Zombie instead of Humanoid in the past, your AI Zombie scripts must have been messed up after changing the name.
Yeah and I have changed everything I can find to Humanoid but they still are doing nothing
Hm ok, try changing it back then. See if the zombies start working again.