generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Select random player script not working

Previous Thread :: Next Thread 
smartlegomaniac is not online. smartlegomaniac
Joined: 16 Jun 2012
Total Posts: 411
14 Dec 2016 07:12 PM
This script is supposed to choose a random player and after killing them it should allow you to choose another player. After clicking the text button and killing the player twice the script stops working. I haven't had any errors. Does anyone know what is wrong with the script? Here it is:

script.Parent.MouseButton1Click:connect(function()
local players = game.Players:GetPlayers()
if #players > 1 then
script.Parent.Text = "Target Found"
wait(1)
script.Parent.Visible = false
script.Parent.Text = "Request Target"
repeat target = players[math.random(#players)]
until target.Name ~= game.Players.LocalPlayer.Name
script.Parent.Parent.targetdisplay.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..target.Name
script.Parent.Parent.targetdisplay.TextLabel.Text = target.Name
script.Parent.Parent.targetdisplay.Position = UDim2.new(0,-185,1,-295)
for i=1,5 do
script.Parent.Parent.targetdisplay.Position = script.Parent.Parent.targetdisplay.Position + UDim2.new(0,41,0,0)
wait()
end
target.Character.Humanoid.HealthChanged:connect(function()
if target.Character.Humanoid.Health <= 0 then
script.Parent.Parent.targetdisplay.Position = UDim2.new(0,20,1,-295)
for i=1,5 do
script.Parent.Parent.targetdisplay.Position = script.Parent.Parent.targetdisplay.Position - UDim2.new(0,41,0,0)
wait()
end
script.Parent.Visible = true
target = nil
end
end)
else
script.Parent.Text = "No Target Found"
wait(1)
script.Parent.Text = "Request Target"
end
end)

game.Players.PlayerRemoving:connect(function(player)
if target ~= nil and player.Name == target.Name then
script.Parent.Parent.targetdisplay.Position = UDim2.new(0,20,1,-295)
for i=1,5 do
script.Parent.Parent.targetdisplay.Position = script.Parent.Parent.targetdisplay.Position - UDim2.new(0,41,0,0)
wait()
end
script.Parent.Visible = true
target = nil
end
end)
Report Abuse
smartlegomaniac is not online. smartlegomaniac
Joined: 16 Jun 2012
Total Posts: 411
14 Dec 2016 07:23 PM
Bump
Report Abuse
Talaryn is not online. Talaryn
Joined: 24 Feb 2016
Total Posts: 41
14 Dec 2016 07:26 PM
sorry a script this long without indentation is next to impossible to read


Report Abuse
SinisterMemories is not online. SinisterMemories
Joined: 21 Mar 2013
Total Posts: 4892
14 Dec 2016 07:26 PM
player = {me,kef,sin,lol,ideksin}
PickPlayer = tab[math.random(1, #player)]
table.remove(player,PickPlayer)


Report Abuse
smartlegomaniac is not online. smartlegomaniac
Joined: 16 Jun 2012
Total Posts: 411
14 Dec 2016 07:28 PM
script.Parent.MouseButton1Click:connect(function()
local players = game.Players:GetPlayers()
if #players > 1 then
script.Parent.Text = "Target Found"
wait(1)
script.Parent.Visible = false
script.Parent.Text = "Request Target"
repeat target = players[math.random(#players)]
until target.Name ~= game.Players.LocalPlayer.Name
script.Parent.Parent.targetdisplay.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&username="..target.Name
script.Parent.Parent.targetdisplay.TextLabel.Text = target.Name
script.Parent.Parent.targetdisplay.Position = UDim2.new(0,-185,1,-295)
for i=1,5 do
# script.Parent.Parent.targetdisplay.Position = script.Parent.Parent.targetdisplay.Position + UDim2.new(0,41,0,0)
wait()
end
target.Character.Humanoid.HealthChanged:connect(function()
if target.Character.Humanoid.Health <= 0 then
script.Parent.Parent.targetdisplay.Position = UDim2.new(0,20,1,-295)
for i=1,5 do
# script.Parent.Parent.targetdisplay.Position = script.Parent.Parent.targetdisplay.Position - UDim2.new(0,41,0,0)
wait()
end
script.Parent.Visible = true
target = nil
end
end)
else
script.Parent.Text = "No Target Found"
wait(1)
script.Parent.Text = "Request Target"
end
end)

game.Players.PlayerRemoving:connect(function(player)
if target ~= nil and player.Name == target.Name then
script.Parent.Parent.targetdisplay.Position = UDim2.new(0,20,1,-295)
for i=1,5 do
# script.Parent.Parent.targetdisplay.Position = script.Parent.Parent.targetdisplay.Position - UDim2.new(0,41,0,0)
wait()
end
script.Parent.Visible = true
target = nil
end
end)
Report Abuse
smartlegomaniac is not online. smartlegomaniac
Joined: 16 Jun 2012
Total Posts: 411
14 Dec 2016 07:45 PM
Bump
Report Abuse
smartlegomaniac is not online. smartlegomaniac
Joined: 16 Jun 2012
Total Posts: 411
14 Dec 2016 08:04 PM
bump
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
14 Dec 2016 08:08 PM
player = game.Players:GetPlayers()[math.random(1, #game.Players:GetPlayers())]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image