local event=game.ReplicatedStorage:WaitForChild("WebSpawn")
local event2=game.ReplicatedStorage:WaitForChild("WebLength")
event.OnServerEvent:Connect(function(player, attachment, pos, canShoot, ropeObj)
if canShoot.Value==true then --if player can shoot
canShoot.Value=false
--setting up the rope
local rope=Instance.new("RopeConstraint")
rope.Thickness = 0.2
rope.Restitution=0.8
rope.Color = BrickColor.new("White")
rope.Visible=true;
rope.Enabled=false
ropeObj.Value=rope
local attachment0 = attachment
local attachment1 = Instance.new("Attachment")
rope.Attachment0 = attachment0
rope.Attachment1 = attachment1
rope.Parent = workspace.Terrain
attachment1.Parent = workspace.Terrain
attachment1.Position = pos
local magnitude = (attachment0.Position - attachment0.Position).Magnitude
if magnitude<300 then
rope.Length=magnitude
wait()
rope.Enabled=true
while rope.Length>1 and rope.Enabled do
wait()
end
end
rope:Destroy();
wait(1)
canShoot.Value=true
end
end)
So I immediately notice you are subtracting attachment0 from attachment0, which would equate to 0. Secondly, if the magnitude is over 300, it will never successfully run the desired code.
Yes at first i used two variables (start and finish) to store the positions and i realized before posting that they are useless, i edited and that’s when i made the mistakes.
now i have like this, but it still doesn’t seem to work
local magnitude = math.abs((attachment0.Position - attachment1.Position).Magnitude)