You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Although my script is fine the way it is, I want to reduce clutter and make it only spawn one rope. I would also try to find a way to not use the function(hit) event.
-
What is the issue? Include screenshots / videos if possible!
This just needs to be much easier to use and so I can do more with it with less time.
Here is what I got so far:
Balloon-Blimp Looking Thing
Zipline
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I wanted to find a way to do this without the touched event as you can do it lots of times.
TweenService with the touching event is very hard to work with, so I used Position. The only problem; it is very inconvenient. Is there a way to fix this?
Zipline and Balloon both are the same main script with modifications.
script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent then
local Part1 = game.Workspace.Bal2
local Part2 = hit
local Rope = Instance.new("RopeConstraint", Part1)
local A1 = Instance.new("Attachment", Part1)
local A2 = Instance.new("Attachment", Part2)
Rope.Attachment0 = A1
Rope.Attachment1 = A2
Rope.Length = 17
Rope.Visible = true
Rope.Color = BrickColor.new("Lilac")
wait(1)
game:GetService("TweenService"):Create(Part1,TweenInfo.new(3,Enum.EasingStyle.Elastic),{Position = Vector3.new(50.5, 70.5, 101)}):Play()
wait(3)
Part1:ClearAllChildren()
wait(1)
game:GetService("TweenService"):Create(Part1,TweenInfo.new(3,Enum.EasingStyle.Elastic),{Position = Vector3.new(118.5, 70.5, 177)}):Play()
wait(0.4)
script.Disabled = true
wait(3)
script.Disabled = false
end
end)
As this being my first support post, if there is something I need to do, just mention me. Thanks!
I believe there is no real way to figure out if a Player is Touching a part without the Touched
Event, but I might be wrong on that.
To prevent multiple ropes from spawning, you can check if the player has already a rope in them, and if they do, don’t execute the script.
if workspace.Bal2:FindFirstChild(hit.Parent.Name) then return end
And then you rename your Rope
Instance to the Character’s Name, like this:
Rope.Name = hit.Parent.Name
Now each time the Touched Event triggers, it checks if there is already a rope, and if there is, don’t execute the code. Just make sure you :Destroy()
the rope after you are done using it.
The modified code with above mentioned solution should look like this:
script.Parent.Touched:Connect(function(hit)
if workspace.Bal2:FindFirstChild(hit.Parent.Name) then return end
if hit and hit.Parent then
local Part1 = game.Workspace.Bal2
local Part2 = hit
local Rope = Instance.new("RopeConstraint", Part1)
local A1 = Instance.new("Attachment", Part1)
local A2 = Instance.new("Attachment", Part2)
Rope.Name = hit.Parent.Name
Rope.Attachment0 = A1
Rope.Attachment1 = A2
Rope.Length = 17
Rope.Visible = true
Rope.Color = BrickColor.new("Lilac")
wait(1)
game:GetService("TweenService"):Create(Part1,TweenInfo.new(3,Enum.EasingStyle.Elastic),{Position = Vector3.new(50.5, 70.5, 101)}):Play()
wait(3)
Part1:ClearAllChildren()
wait(1)
game:GetService("TweenService"):Create(Part1,TweenInfo.new(3,Enum.EasingStyle.Elastic),{Position = Vector3.new(118.5, 70.5, 177)}):Play()
wait(0.4)
script.Disabled = true
wait(3)
script.Disabled = false
-- Don't forget to destroy Rope in the end
end
end)
2 Likes
script.Parent.Touched:Connect(function(hit)
if workspace.Bal2:FindFirstChild(hit.Parent.Name) then return end
if hit and hit.Parent then
local Part1 = game.Workspace.TestBal
local Part2 = hit
local Rope = Instance.new("RopeConstraint", Part1)
local A1 = Instance.new("Attachment", Part1)
local A2 = Instance.new("Attachment", Part2)
Rope.Name = hit.Parent.Name
Rope.Attachment0 = A1
Rope.Attachment1 = A2
Rope.Length = 17
Rope.Visible = true
Rope.Color = BrickColor.new("Flint")
wait(1)
game:GetService("TweenService"):Create(Part1,TweenInfo.new(3,Enum.EasingStyle.Elastic),{Position = Vector3.new(-104.5, 51.5, 182.5)}):Play()
wait(3)
Part1:ClearAllChildren()
wait(1)
game:GetService("TweenService"):Create(Part1,TweenInfo.new(3,Enum.EasingStyle.Elastic),{Position = Vector3.new(-104.5, 21.5, 182.5)}):Play()
wait(0.4)
script.Disabled = true
wait(3)
script.Disabled = false
Rope:Destroy()
end
end)
I added the Rope:Destroy()
event to your modified script, and yet, it still manages to spawn more than one rope.