OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 09:28 AM |
--This script is supposed to search through the workspace, looking for an object with a child script named after the player that just left. The script is a serverscript in the ServerScriptService. Thanks in advance!
local parent = script.Parent local dominantPlayer local victimPlayer local victimPlayerChar local workspaceChild = game.Workspace:GetChildren()
game.Players.PlayerRemoving:connect(function(player) print("player left") for i = 1, #workspaceChild do print("scanning object") if workspaceChild[i]:FindFirstChild(player.Name) then print("found player") dominantPlayer = player victimPlayer = game.Players:FindFirstChild(workspaceChild[i].Name) victimPlayerChar = workspaceChild[i] local link = victimPlayerChar:FindFirstChild(dominantPlayer.Name) local invincibility = victimPlayerChar.Invincibility link:Destroy() invincibility:Destroy() victimPlayerChar.Humanoid.MaxHealth = 100 local returnTools = game.ReplicatedStorage.ReturnTools:Clone() returnTools.Parent = victimPlayerChar returnTools.Disabled = false break end end end)
--Online |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 09:29 AM |
Forgot to mention, "found player" never prints.
--Online |
|
|
| Report Abuse |
|
|
Salinas23
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 37141 |
|
|
| 13 Nov 2016 09:32 AM |
for _, child in pairs (#workspaceChild") do
I have a spider on my back. |
|
|
| Report Abuse |
|
|
|
| 13 Nov 2016 09:33 AM |
| Then the object most likely is not a great child of workspace but a deeper descendant or just doesn't exist at all. Since the rest of that script, atleast up to the print looks fine. |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 09:43 AM |
No, I'm fairly certain that it is. I looked at the objects myself, and they all seem correct. Also, to the guy two posts up, my for loop is fine.
--Online |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 10:18 AM |
Workspace victimPlayer[player we're removing the scripts from] dominantPlayer[script's name] Players dominantPlayer[player that just left] victimPlayer[player]
--Online |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 10:25 AM |
Someone, please help. Still deosn't work.
--Online |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
| |
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 10:39 AM |
Bump. Help please.
--Online |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
| |
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
| |
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 10:56 AM |
why is nobody responding
--Online |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 11:00 AM |
I've been working on this for 4 hours, why wont it work?
--Online |
|
|
| Report Abuse |
|
|
caca50
|
  |
| Joined: 10 Jul 2011 |
| Total Posts: 2037 |
|
|
| 13 Nov 2016 11:01 AM |
local parent = script.Parent local dominantPlayer local victimPlayer local victimPlayerChar
game.Players.PlayerRemoving:connect(function(player) local workspaceChild = game.Workspace:GetChildren() print("player left") for i = 1, #workspaceChild do print("scanning object") if workspaceChild[i]:FindFirstChild(player.Name,true) then print("found player") dominantPlayer = player victimPlayer = game.Players:FindFirstChild(workspaceChild[i].Name) victimPlayerChar = workspaceChild[i]
local link = victimPlayerChar:FindFirstChild(dominantPlayer.Name) local invincibility = victimPlayerChar.Invincibility
link:Destroy() invincibility:Destroy()
victimPlayerChar.Humanoid.MaxHealth = 100
local returnTools = game.ReplicatedStorage.ReturnTools:Clone() returnTools.Parent = victimPlayerChar returnTools.Disabled = false
break end end end) |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 11:03 AM |
you are my hero and savior, it works. thanks a lot
--Online |
|
|
| Report Abuse |
|
|
OnlineOne
|
  |
| Joined: 14 Jul 2011 |
| Total Posts: 1193 |
|
|
| 13 Nov 2016 11:04 AM |
I can't believe that I missed that the workspace's children change
--Online |
|
|
| Report Abuse |
|
|