Im making a horror game and this is the script to pick someone random from Players But it dosent work can you help me?
Heres the script:
local Player = game.Players:GetPlayers() local Formof = script.Parent local Weapon = Game.ReplicatedStorage:FindFirstChild('Knife') Weapon.Parent = Player.BackPack Chance = Players[math.randomseed(#players)] if Player == script.Parent then script.Parent.Health = 2000 script.Parent.Walkspeed = 52 script.Parent.MaxHealth = 2000 end
I didn't do this, but I'd recommend putting in a while true do loop with each variable within the loop so every minute or so, a new person would be picked. Here's your script fixed up.
local Player = game.Players:GetPlayers() local Formof = script.Parent local Weapon = Game.ReplicatedStorage:FindFirstChild('Knife') Chance = Player[math.random(1, #Player)] SelectedPlayerName = Chance.Name if Chance then Chance.Character.Humanoid.Health = 2000 Chance.Character.Humanoid.Walkspeed = 52 Chance.Character.Humanoid.MaxHealth = 2000 Weapon:clone().Parent = Chance.Backpack end
I'm not sure what you're trying to do with the Health, but could you comment what you're trying to do?