Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

having issues getting two if statements getting a single while loop to function?

Asked by
Hizar7 102
6 years ago

here is my issue I am trying to get two guys to do whats in the while loop. which is to follow the player and to return to their spawn, but i cant seem to get this right.. I just made this script in this for an example.. Please help!

01local h = game.Workspace.guy1.Humanoid
02local b = game.Workspace.guy2.Humanoid
03local UpperTorso = game.Workspaceguy1.UpperTorso
04local UpperTorsoA = game.Workspace.guy2.UpperTorso
05local spawnCF = UpperTorso.CFrame
06local spawnCFA = UpperTorsoA.CFrame
07 
08function findPlayer()
09 for _,v in next, game.Players:GetPlayers() do
10  if v.Character then
11   local char = v.Character
12   if char:FindFirstChild("Humanoid") and char:FindFirstChild("UpperTorso") then
13    local pUpperTorso = char.UpperTorso
14    if (pUpperTorso.Position - UpperTorso.Position).magnitude <= 30 then
15    else h = nil
View all 40 lines...
0
indentation 10/10 aazkao 787 — 6y
0
I think the funky indentation is roblox's fault this time User#21908 42 — 6y
0
You have to put something in an if statement, you can't write "then else" User#22604 1 — 6y
0
If you only want something to run if a condition is NOT true, you can write "if not (yourconditional) then" User#22604 1 — 6y

Answer this question