Hello, I am trying to create a zombie script that can infect other players, However I have a problem or I don't know what the best way is: Now I created a IntValue named "Status", if the value of it is 0 then the player is not infected. If it is one they they are infected. But I want to make it like this: If the player touch the part and if their value is 0 then ZombieGiver() will run and make the value 1. However I get a error with this: 12:30:22.798 - ServerScriptService.Zombie:33: attempt to index nil with 'ZombieData' Does anybody know how to fix this or make it in a better way?
Btw, Both scripts are in ServerScriptService
game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder")
folder.Parent = player
folder.Name = "ZombieData"
local status = Instance.new("IntValue")
status.Value = 0
status.Name = "Status"
status.Parent = folder
end)
I know that there is a better way to color all the parts.
function ZombieGiver(player)
local Human = player.Parent:findFirstChild("Humanoid")
Human.Parent.LeftFoot.BrickColor = BrickColor.new("Burnt Sienna")
Human.Parent.LeftHand.BrickColor = BrickColor.new("Artichoke")
Human.Parent.LeftLowerArm.BrickColor = BrickColor.new("Artichoke")
Human.Parent.LeftLowerLeg.BrickColor = BrickColor.new("Burnt Sienna")
Human.Parent.LeftUpperArm.BrickColor = BrickColor.new("Artichoke")
Human.Parent.LeftUpperLeg.BrickColor = BrickColor.new("Burnt Sienna")
Human.Parent.LowerTorso.BrickColor = BrickColor.new("Burnt Sienna")
Human.Parent.RightHand.BrickColor = BrickColor.new("Artichoke")
Human.Parent.RightLowerArm.BrickColor = BrickColor.new("Artichoke")
Human.Parent.RightLowerLeg.BrickColor = BrickColor.new("Burnt Sienna")
Human.Parent.RightUpperArm.BrickColor = BrickColor.new("Artichoke")
Human.Parent.RightUpperLeg.BrickColor = BrickColor.new("Burnt Sienna")
Human.Parent.UpperTorso.BrickColor = BrickColor.new("Burnt Sienna")
Human.Parent.Head.BrickColor = BrickColor.new("Artichoke")
Human.Parent.Head.face.Texture = "http://www.roblox.com/asset/?id=174393211"
Human.Parent.Shirt.ShirtTemplate = "http://www.roblox.com/asset/0"
Human.Parent.Pants.PantsTemplate = "http://www.roblox.com/asset/0"
Human.Parent.Animate.run.RunAnim.AnimationId = "http://www.roblox.com/asset/?id=616168032"
Human.Parent.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=616158929"
Human.Parent.Animate.idle.Animation2.AnimationId = "http://www.roblox.com/asset/?id=616160636"
Human.Parent.Animate.jump.JumpAnim.AnimationId = "http://www.roblox.com/asset/?id=616161997"
Human.Parent.Animate.climb.ClimbAnim.AnimationId = "http://www.roblox.com/asset/?id=616156119"
end
local zombie = game.Workspace.Part
zombie.Touched:Connect(function(player)
if game.Players.LocalPlayer.ZombieData.Status == 0 then
ZombieGiver(player)
end
end)

2 comments
Thank you so mutch! Its works very well now :D I got the same error: ServerScriptService.Zombie:34: attempt to index nil with 'ZombieData' but isn't a big of a deal. Thanks!
oh ok np