generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: stack overflow

Previous Thread :: Next Thread 
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
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
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
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 is not online. 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
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
04 Jun 2016 12:57 PM
ohhhhh
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
04 Jun 2016 01:01 PM
for some reason it says i havent stated what "cannonball" is
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
04 Jun 2016 02:22 PM
bump
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
05 Jun 2016 12:25 AM
You need to put that ShootCannonBall function at the top of your script.


Report Abuse
MetaCoder is not online. 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
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
05 Jun 2016 01:15 AM
a wait won't fix a stack over flow


Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
05 Jun 2016 10:47 AM
still cant seem to solve it

bump?
Report Abuse
eqis is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image