|
| 31 Jan 2015 11:37 PM |
This may seem easy and stupid to you, but i'm still learning new things constantly. So I want my boat to drop off said zombies, and leave but it sticks around after dropping them off. is there anyway I can fix this? I don't know what it is so I posted the related function below.
function byboat() Boatc = Boat:Clone() Empty_Boatc = Empty_Boat:Clone() Boatc.Parent = game.Lighting Boat.Parent = game.Workspace for i = 1,429 do wait() game.Workspace.Boat:MoveTo(Vector3.new(-449.4, 1.8, i)) -- -108.5 if i >= 429 then Wave1.Parent = game.Workspace Boat:Destroy() Boat.Name = "Boat" Empty_Boatc.Parent = game.Workspace for k = 1,-429 do game.Workspace.Empty_Boat:MoveTo(Vector3.new(-449.4, 1.8, k)) -- -108.5 if k >= -429 then Empty_Boatc:Destroy() end end end end end |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 31 Jan 2015 11:40 PM |
| At which point in your script is the boat supposed to turn around and leave? |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
| |
|
|
| 31 Jan 2015 11:41 PM |
for k = 1,-429 do game.Workspace.Empty_Boat:MoveTo(Vector3.new(-449.4, 1.8, k)) -- -108.5 if k >= -429 then
I want the Empty_Boat to just go back, like it came forward in the first part. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 31 Jan 2015 11:43 PM |
Why not just put that line AFTER the for loop?
for k = 1,-429 do -- do stuff end game.Workspace.Empty_Boat:MoveTo(Vector3.new(-449.4, 1.8, k))
See how that works? The MoveTo line will be executed after the for loop. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 31 Jan 2015 11:43 PM |
| What I just posted isn't a solution to your problem. I'm just trying to suggest ways to make your code a little more understandable. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 31 Jan 2015 11:45 PM |
| I think that would defeat the purpose of the for loop (tweening the boat away), however that "Empty_Boat:Destroy()" part should be after the for loop. Same with what the similar thing he tried above. |
|
|
| Report Abuse |
|
|
|
| 31 Jan 2015 11:48 PM |
Because I thought that it wouldn't execute the variable 'k' to move the part then. I want it like a steady moving of the part, like an elevator, I don't want it to teleport there.
If i was doing a for loop can you put it out and have it work? I don't think so..
p = Instance.new("Part,workspace)
for i = 1,100 do while true do wait() p.CFrame = CFrame.new(0,0,0 + i) end end
I may be incorrect, (I learned all I know from youtube and the wiki so I mess up on simple things sometimes.) |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 31 Jan 2015 11:52 PM |
| Oh you're right. For some reason I was thinking of Humanoid:MoveTo. |
|
|
| Report Abuse |
|
|
|
| 31 Jan 2015 11:54 PM |
| The problem is that instead of moving back, the boat stays in the same position. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 31 Jan 2015 11:56 PM |
for k = 1,-429 do should be for k = 1,-429,-1 do
That's the quickest fix to your problem. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 31 Jan 2015 11:56 PM |
Okay so put a print statement after this line:
if i >= 429 then print("got past")
That way you can tell if that code actually gets executed. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 31 Jan 2015 11:57 PM |
| And the reason you have to do that is because naturally it wants to count to the second number by one. Since the number is below the first number, it needs to count by negative one. |
|
|
| Report Abuse |
|
|
|
| 31 Jan 2015 11:58 PM |
| using that the boat instantly just dissapears. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 31 Jan 2015 11:59 PM |
| Because you never halted the thread any. Add a wait in there like you did with your first loop. |
|
|
| Report Abuse |
|
|
|
| 01 Feb 2015 12:01 AM |
Yes, it prints that it got past it then I get the error
got past 23:59:48.221 - Empty_Boat is not a valid member of Workspace
(I was also using his suggestion with the addition of the ,-1 if that makes a difference.) |
|
|
| Report Abuse |
|
|
|
| 01 Feb 2015 12:03 AM |
Here is what I have for that function now:
function byboat() Boatc = Boat:Clone() Empty_Boatc = Empty_Boat:Clone() Boatc.Parent = game.Lighting Boat.Parent = game.Workspace for i = 1,429 do wait() game.Workspace.Boat:MoveTo(Vector3.new(-449.4, 1.8, i)) -- -108.5 if i >= 429 then Wave1.Parent = game.Workspace Boat:Destroy() Boat.Name = "Boat" Empty_Boatc.Parent = game.Workspace for k = 1,-429,-1 do wait() game.Workspace.Empty_Boat:MoveTo(Vector3.new(-449.4, 3.6, i)) -- -108.5 if i >= 429 then print("got past") Empty_Boatc:Destroy() end end end end end |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 01 Feb 2015 12:05 AM |
function byboat() local Boatc = Boat:Clone() Boat.Parent = game.Workspace for i = 1, 429 do game.Workspace.Boat:MoveTo(Vector3.new(-449.4, 1.8, i)) -- -108.5 wait() end Wave1.Parent = game.Workspace Boat:Destroy() -- shouldn't this be Boatc? If so change the next line too. Boat = nil local Empty_Boatc = Empty_Boat:Clone() Empty_Boatc.Parent = game.Workspace for i = 429, 1, -1 do game.Workspace.Empty_Boat:MoveTo(Vector3.new(-449.4, 1.8, i)) -- -108.5 end Empty_Boatc:Destroy() end end end end
Check syntax. I can't really tell if there's a proper amount of ends or not without whitespace. |
|
|
| Report Abuse |
|
|
|
| 01 Feb 2015 12:09 AM |
| That works even worse because the boat still doesnt move and it never changes to the empty boat. |
|
|
| Report Abuse |
|
|
| |
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 01 Feb 2015 12:20 AM |
function byboat() local Boatc = Boat:Clone() Boat.Parent = game.Workspace for i = 1, 429 do Boatc:MoveTo(Vector3.new(-449.4, 1.8, i)) -- -108.5 wait() end Wave1.Parent = game.Workspace Boatc:Destroy() Boatc = nil local Empty_Boatc = Empty_Boat:Clone() Empty_Boatc.Parent = game.Workspace for i = 429, 1, -1 do Empty_Boatc:MoveTo(Vector3.new(-449.4, 1.8, i)) -- -108.5 end Empty_Boatc:Destroy() Empty_Boatc = nil end end end end
You'll have to provide an output or something for further debugging. |
|
|
| Report Abuse |
|
|
anaIyze
|
  |
| Joined: 29 May 2014 |
| Total Posts: 2048 |
|
|
| 01 Feb 2015 12:22 AM |
| why don't you just make a waypoint |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|