|
| 04 Jun 2016 12:48 PM |
thats what it says for lines 2 and 13
script:
function ShootCannonBall() local cannonball = Instance.new("Part") cannonball.Shape = "Ball" cannonball.Size = Vector3.new(6.2, 6.2, 6.2) cannonball.CanCollide = false cannonball.Material = "Slate" cannonball.BrickColor = BrickColor.Gray() cannonball.Position = script.Parent.Position + Vector3.new(0, 0, 3) local force = Instance.new("BodyThrust") force.force = Vector3.new(0, 5000, 0) force.location = game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(0, 0, 5) ShootCannonBall() cannonball.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then local hitted = hit.Parent:FindFirstChild("Humanoid") hitted.Health = hitted.Health - 20 local kaboom = Instance.new("Explosion") kaboom.Parent = cannonball kaboom.Position = cannonball.Position cannonball:Destroy() end end) end
workspace.ActivatorPart.Touched:connect(ShootCannonBall)
localscript in a part |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 12:52 PM |
you are calling the function inside the function which is a recursive function. but as theres no break in it means it calls it infinity times but recursive functions have a cap of 255 calls before it gives you that error.
By the look of the code you did not mean for it to be a recursuve function and it just a misplaced end
function ShootCannonBall() local cannonball = Instance.new("Part") cannonball.Shape = "Ball" cannonball.Size = Vector3.new(6.2, 6.2, 6.2) cannonball.CanCollide = false cannonball.Material = "Slate" cannonball.BrickColor = BrickColor.Gray() cannonball.Position = script.Parent.Position + Vector3.new(0, 0, 3) local force = Instance.new("BodyThrust") force.force = Vector3.new(0, 5000, 0) force.location = game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(0, 0, 5) end ShootCannonBall() cannonball.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then local hitted = hit.Parent:FindFirstChild("Humanoid") hitted.Health = hitted.Health - 20 local kaboom = Instance.new("Explosion") kaboom.Parent = cannonball kaboom.Position = cannonball.Position cannonball:Destroy() end end)
workspace.ActivatorPart.Touched:connect(ShootCannonBall)
|
|
|
| Report Abuse |
|
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
|
| 04 Jun 2016 12:52 PM |
| Stack overflow means you've given the computer more work than it can handle. Instead of freezing it gives you that error. There's probably something else in the output. And btw something like this should be handled server-side. |
|
|
| Report Abuse |
|
|
| |
|
|
| 04 Jun 2016 01:01 PM |
| for some reason it says i havent stated what "cannonball" is |
|
|
| Report Abuse |
|
|
| |
|
|
| 05 Jun 2016 12:25 AM |
You need to put that ShootCannonBall function at the top of your script.
|
|
|
| Report Abuse |
|
|
MetaCoder
|
  |
| Joined: 16 Apr 2016 |
| Total Posts: 52 |
|
|
| 05 Jun 2016 01:07 AM |
function ShootCannonBall() local cannonball = Instance.new("Part") cannonball.Shape = "Ball" cannonball.Size = Vector3.new(6.2, 6.2, 6.2) cannonball.CanCollide = false cannonball.Material = "Slate" cannonball.BrickColor = BrickColor.Gray() cannonball.Position = script.Parent.Position + Vector3.new(0, 0, 3) local force = Instance.new("BodyThrust") force.force = Vector3.new(0, 5000, 0) force.location = game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(0, 0, 5)
ShootCannonBall() cannonball.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then local hitted = hit.Parent:FindFirstChild("Humanoid") hitted.Health = hitted.Health - 20 local kaboom = Instance.new("Explosion") kaboom.Parent = cannonball kaboom.Position = cannonball.Position wait(0.1) cannonball:Destroy() end end) end
workspace.ActivatorPart.Touched:connect(ShootCannonBall)
|
|
|
| Report Abuse |
|
|
|
| 05 Jun 2016 01:15 AM |
a wait won't fix a stack over flow
|
|
|
| Report Abuse |
|
|
|
| 05 Jun 2016 10:47 AM |
still cant seem to solve it
bump? |
|
|
| Report Abuse |
|
|
eqis
|
  |
| Joined: 31 Dec 2008 |
| Total Posts: 295 |
|
|
| 05 Jun 2016 11:27 AM |
It's pretty simple, the part where you call the function from within itself needs an exit condition or it needs to change.
function ShootCannonBall() local cannonball = Instance.new("Part") cannonball.Shape = "Ball" cannonball.Size = Vector3.new(6.2, 6.2, 6.2) cannonball.CanCollide = false cannonball.Material = "Slate" cannonball.BrickColor = BrickColor.Gray() cannonball.Position = script.Parent.Position + Vector3.new(0, 0, 3) local force = Instance.new("BodyThrust") force.force = Vector3.new(0, 5000, 0) force.location = game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(0, 0, 5)
cannonball.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then local hitted = hit.Parent:FindFirstChild("Humanoid") hitted.Health = hitted.Health - 20 local kaboom = Instance.new("Explosion") kaboom.Parent = cannonball kaboom.Position = cannonball.Position cannonball:Destroy() end end) end |
|
|
| Report Abuse |
|
|