I am making a zombie game and when I spawn in it gives me this error
It happens when I try to change the players walkspeed.
Here is the script:
while true do -- This is where it starts :)
wait()
if game.Workspace.MainScript.Teleport.Value == true then
script.CamFix.Disabled = false
script.Parent.Parent.Playing.Value = true
game.Workspace.MainScript.StartPlayers.Value = game.Workspace.MainScript.StartPlayers.Value + 1
player.Character.HumanoidRootPart.CFrame = workspace.TeleportDestination.CFrame
local random = math.random(1,8)
if random == 1 then
game.Lighting.ClassTools.Sterling:Clone().Parent = player.Backpack
player.Character.Humanoid.Walkspeed = 16
player.Character.Humanoid.MaxHealth = 140
player.Character.Humanoid.Health = 140
end
if random == 2 then
game.Lighting.ClassTools.Thompson:Clone().Parent = player.Backpack
player.Character.Humanoid.Walkspeed = 16
player.Character.Humanoid.MaxHealth = 140
player.Character.Humanoid.Health = 140
end
if random == 3 then
game.Lighting.ClassTools.Uzi:Clone().Parent = player.Backpack
player.Character.Humanoid.Walkspeed = 16
player.Character.Humanoid.MaxHealth = 140
player.Character.Humanoid.Health = 140
end
if random == 4 then
game.Lighting.ClassTools.M1911:Clone().Parent = player.Backpack
player.Character.Humanoid.Walkspeed = 18
player.Character.Humanoid.MaxHealth = 160
player.Character.Humanoid.Health = 160
end
if random == 5 then
game.Lighting.ClassTools.Deagle:Clone().Parent = player.Backpack
player.Character.Humanoid.Walkspeed = 18
player.Character.Humanoid.MaxHealth = 160
player.Character.Humanoid.Health = 160
end
if random == 6 then
game.Lighting.ClassTools.MeleeAxe:Clone().Parent = player.Backpack
player.Character.Humanoid.Walkspeed = 18
player.Character.Humanoid.MaxHealth = 160
player.Character.Humanoid.Health = 160
end
if random == 7 then
game.Lighting.ClassTools.MeleeBar:Clone().Parent = player.Backpack
player.Character.Humanoid.Walkspeed = 18
player.Character.Humanoid.MaxHealth = 160
player.Character.Humanoid.Health = 160
end
if random == 8 then
game.Lighting.ClassTools.MeleeWrench:Clone().Parent = player.Backpack
player.Character.Humanoid.Walkspeed = 18
player.Character.Humanoid.MaxHealth = 160
player.Character.Humanoid.Health = 160
end
gamepass_guns() -- Ignore this
wait(5)
end
end
What am I doing wrong?