i’m trying to make a balloon tool that lets you summon 5 balloons but i dont know how to make the balloons destroy after a couple of seconds. i tried adding Destroy() but it wouldnt get rid of new balloons. here is my script: local rope
local att0
local att1
local newRope
local BV
local NewBalloon
local BalloonAmount = 5
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,target,hit)
if rope == nil then
if target == nil then return end
if target:IsA(‘Sky’) or target:IsA(‘Atmosphere’) or target == nil or target.Name == “Baseplate” then return end
if target.Name ~= ‘Baseplate’ then
if (script.Parent.Parent.Parent.BalloonTool.Handle.String.Position - target.Position).Magnitude > 30 then return end
BV = Instance.new(‘BodyVelocity’)
rope = Instance.new(‘RopeConstraint’)
att0 = Instance.new(‘Attachment’)
att1 = Instance.new(‘Attachment’)
NewBalloon = script.Parent.Parent.Handle:Clone()
att0.Parent = target
att1.Parent = NewBalloon.String
rope.Visible = true
rope.Parent = NewBalloon.String
rope.Attachment0 = att0
rope.Attachment1 = att1
rope.Length = (script.Parent.Parent.Parent.BalloonTool.Handle.String.Position - target.Position).Magnitude
BV.Parent = NewBalloon
BV.Parent.BodyVelocity.Velocity = Vector3.new(0, 10, 0)
BV.Parent.BodyVelocity.MaxForce = Vector3.new(100000000000, 10000000000, 100000000000)
BV.Parent.BodyVelocity.P = 3000
NewBalloon.Name = “Balloon”
NewBalloon.Parent = workspace.Map
BalloonAmount -= 1
end
if BalloonAmount < 1 then
script.Parent.Parent:Destroy()
end
else
rope = nil
att0 = nil
att1 = nil
if newRope ~= nil then
newRope:Destroy()
newRope = nil
end
end
end)
1 Like
Nico_Nic77
(Silly_dev1338)
January 15, 2024, 7:24pm
#2
chapper:
local att0
local att1
local newRope
local BV
local NewBalloon
local BalloonAmount = 5
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,target,hit)
if rope == nil then
if target == nil then return end
if target:IsA(‘Sky’) or target:IsA(‘Atmosphere’) or target == nil or target.Name == “Baseplate” then return end
if target.Name ~= ‘Baseplate’ then
if (script.Parent.Parent.Parent.BalloonTool.Handle.String.Position - target.Position).Magnitude > 30 then return end
BV = Instance.new(‘BodyVelocity’)
rope = Instance.new(‘RopeConstraint’)
att0 = Instance.new(‘Attachment’)
att1 = Instance.new(‘Attachment’)
NewBalloon = script.Parent.Parent.Handle:Clone()
att0.Parent = target
att1.Parent = NewBalloon.String
rope.Visible = true
rope.Parent = NewBalloon.String
rope.Attachment0 = att0
rope.Attachment1 = att1
rope.Length = (script.Parent.Parent.Parent.BalloonTool.Handle.String.Position - target.Position).Magnitude
BV.Parent = NewBalloon
BV.Parent.BodyVelocity.Velocity = Vector3.new(0, 10, 0)
BV.Parent.BodyVelocity.MaxForce = Vector3.new(100000000000, 10000000000, 100000000000)
BV.Parent.BodyVelocity.P = 3000
NewBalloon.Name = “Balloon”
NewBalloon.Parent = workspace.Map
please format this the same way as here:
Nico_Nic77
(Silly_dev1338)
January 15, 2024, 7:25pm
#3
I sadly can’t help you like that.
How do I format it like that? it automatically did that
its done using " ``` " i think
like
--example
Also, i think it’ll help if you do a delay function as
delay(Time,function()
Ballloon_instance:Destroy()
end
Nico_Nic77
(Silly_dev1338)
January 15, 2024, 7:28pm
#6
yea you use:
````code here 4x `
(I cant do it because then it will format it:
code
```lua
– Add your text here.
```
where do i add the delay thing?
local rope
local att0
local att1
local newRope
local BV
local NewBalloon
local BalloonAmount = 5
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,target,hit)
if rope == nil then
if target == nil then return end
if target:IsA(‘Sky’) or target:IsA(‘Atmosphere’) or target == nil or target.Name == “Baseplate” then return end
if target.Name ~= ‘Baseplate’ then
if (script.Parent.Parent.Parent.BalloonTool.Handle.String.Position - target.Position).Magnitude > 30 then return end
BV = Instance.new(‘BodyVelocity’)
rope = Instance.new(‘RopeConstraint’)
att0 = Instance.new(‘Attachment’)
att1 = Instance.new(‘Attachment’)
NewBalloon = script.Parent.Parent.Handle:Clone()
att0.Parent = target
att1.Parent = NewBalloon.String
rope.Visible = true
rope.Parent = NewBalloon.String
rope.Attachment0 = att0
rope.Attachment1 = att1
rope.Length = (script.Parent.Parent.Parent.BalloonTool.Handle.String.Position - target.Position).Magnitude
BV.Parent = NewBalloon
BV.Parent.BodyVelocity.Velocity = Vector3.new(0, 10, 0)
BV.Parent.BodyVelocity.MaxForce = Vector3.new(100000000000, 10000000000, 100000000000)
BV.Parent.BodyVelocity.P = 3000
NewBalloon.Name = “Balloon”
NewBalloon.Parent = workspace.Map
BalloonAmount -= 1
end
if BalloonAmount < 1 then
script.Parent.Parent:Destroy()
end
else
rope = nil
att0 = nil
att1 = nil
if newRope ~= nil then
newRope:Destroy()
newRope = nil
end
end
end)
im having trouble reading your code, you are trying to delete the balloons after a certain amount of time yes?
1 Like
Nico_Nic77
(Silly_dev1338)
January 15, 2024, 7:35pm
#10
This would be the formatted code:
local rope
local att0,att1
local newRope
local BV
local NewBalloon
local BalloonAmount = 5
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,target,hit)
if rope == nil then
if target == nil then return end
if target:IsA("Sky") or target:IsA("Atmosphere") or target == nil or target.Name == "Baseplate" then return end
if (script.Parent.Parent.Parent.BalloonTool.Handle.String.Position - target.Position).Magnitude > 30 then return end
BV = Instance.new("BodyVelocity")
rope = Instance.new("RopeConstraint")
att0,att1 = Instance.new("Attachment"),Instance.new("Attachment")
NewBalloon = script.Parent.Parent.Handle:Clone()
att0.Parent = target
att1.Parent = NewBalloon.String
rope.Visible = true
rope.Parent = NewBalloon.String
rope.Attachment0 = att0
rope.Attachment1 = att1
rope.Length = (script.Parent.Parent.Parent.BalloonTool.Handle.String.Position - target.Position).Magnitude
BV.Parent = NewBalloon
BV.Parent.BodyVelocity.Velocity = Vector3.new(0, 10, 0)
BV.Parent.BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Parent.BodyVelocity.P = 3000
NewBalloon.Name = "Balloon"
NewBalloon.Parent = workspace.Map
BalloonAmount -= 1
if BalloonAmount < 1 then
script.Parent.Parent:Destroy()
end
else
rope = nil
att0 = nil
att1 = nil
if newRope ~= nil then
newRope:Destroy()
newRope = nil
end
end
end)
1 Like
Yeah, i tried doing this
wait(8)
NewBalloon:Destroy()
but if i added a new balloon, the old ones wouldnt be deleted/destroyed.
Nico_Nic77
(Silly_dev1338)
January 15, 2024, 7:37pm
#12
Okayski now lets get to fixin ur issue:
We’re gonna use the Debris Service like this
local Debris = game:GetService("Debris")
Debris:AddItem(NewBalloon,10) --the number is the lifetime
Sorry for my unformal writing I’m feeling kinda funny today
1 Like
Thank you! Sorry if i didnt understand some stuff because i started to learn coding like 3 months ago so im still a rookie.
1 Like
Nico_Nic77
(Silly_dev1338)
January 15, 2024, 7:40pm
#14
I know this topic is solved - but you should really have a look at Functions (hyperlink) and try improving your code! I think it would make it easier for yourself to find fixes on your own!
Have a nice day/evening/night!
we all have to start somewhere. if you need our help again, come ask
1 Like
system
(system)
Closed
January 29, 2024, 7:40pm
#16
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.