This localscript is supposed to grab all highlighted soldiers a player owns and move them to a target location on the baseplate. The problem occurs around the repeat/until commands with the for loops.
Player = game.Players.LocalPlayer mouse = Player:GetMouse() Character = game.Workspace[Player.name] tool = script.Parent final = false function DownClick() local target = mouse.Target local position = Character.Humanoid.TargetPosiiton if target.Name == "Baseplate" then print ("Press") TargetLocation = Character.Humanoid.TargetPosition -- Create the beacon q = game.Lighting.Beacon:Clone() q.Parent = game.Workspace q.Owner.Value = script.Parent.Parent.Name q.Size = Vector3.new(3,3,3) q.Anchored = false q.CanCollide = false print ("Beacon made") -- Postion it q.Position = CFrame.new(Vector3.new(position)) print ("Positioned") -- Then loop through ones owned by player local Childern = game.Workspace:GetChildren() local MovingSoldiers = {} for _, Child in pairs(Children) do if (string.sub(Child.Name, 1, 7)) == "Soldier" then -- If the first 7 characters make Soldier if Child:findFirstChild("Torso") ~= nil and Child.Folder.Values.Owner.Value == Player then -- Torso exists player owned if Child.Folder.Values.Highlighted == true and Child.Folder.Values.Health > 0 then -- Highlighted and alive if Child.Folder.Values.CanMove == true then table.insert(MovingSoldiers, Child.Name) end end end end end repeat -- Make it move towards the target for i, Soldier in pairs(MovingSoldiers) do local Face = game.Workspace[Soldier].Torso.BodyGyro local Force = game.Workspace[Soldier].Torso.BodyVelocity Face.CFrame = CFrame.new(game.Workspace[Soldier].Torso.Position, CFrame(TargetLocation)) --Face target location Force.Velocity = game.Workspace[Soldier].Torso.CFrame.lookVector * 100 -- Move to target location end until -- The soldiers are within a stud of it, (randomly placed somewhere within a stud) for i, Soldier2 in pairs(MovingSoliders) do Soldier2.Position = target + CFrame.new(math.random(100,-100)/100, 0, math.random(100, -100)) -- Within a stud, on the X and Y Axis end elseif (string.sub(target.Parent.Name, 1, 7)) == "Soldier" then -- If the part's parent is a solider if target.Parent:findFirstChild("Torso") ~= nil and target.Folder.Values.Owner.Value == Player then -- Torso exists player owned if target.parent.Folder.Values.Health > 0 then if target.Folder.Values.Highlighted == true then target.Folder.Values.Highlighted = false elseif target.Folder.Values.Highlighted == false ten target.Folder.Values.Highlighted = true end end end end end mouse.Button1Down:connect(DownClick)
Output:
13:11:53.892 - Players.Player1.Backpack.Beacon.BeaconCreate:46: unexpected symbol near 'for'
The problem is on line 45 you did not put a condition. The repeat statement always needs a condition.
repeat action until condition
You were using repeat and until wrong. Find until and delete it and use repeat like this:
repeat movement until onestud