I'm trying to make a fishing system but there is a problem. If I cast it once or twice it is fine, but on the third time the fishing rod pulls me and the rod with "pointer" or the lure on the end of the line. The pointer seems to also be attached to rod when it should fly off. Does anyone know how to fix this?
local ReplicatedStorage = game:GetService("ReplicatedStorage") local RemoteThrow = ReplicatedStorage:FindFirstChild("RemoteThrow") local RemoteRetract = ReplicatedStorage:FindFirstChild("RemoteRetract") local RemoteSendOwnerName = ReplicatedStorage:FindFirstChild("RemoteSendOwnerName") local Players = game:GetService('Players') local onGround = false local dt = 2 local DBA = false function CreateFishHandler() local NewFishHandler = script.FishHandler:Clone() NewFishHandler.Disabled = false NewFishHandler.Parent = script.Parent end CreateFishHandler() function FishFunc(player, mouse, rootpart, LP) for i, v in pairs(script.Parent.Pointer:GetChildren()) do if v:IsA("ParticleEmitter") then v.Enabled = false end end script.Parent:WaitForChild("FishHandler"):Destroy() local FishingGui = script.Parent.FishingIndicator:Clone() FishingGui.Parent = player.PlayerGui local Number = FishingGui.Frame.ImageLabel.Number script.Parent.StartNumberDrop:Fire(Number) script.Parent.StartNumberDropRE:FireClient(player, Number) script.Parent.ICaughtAFish.Event:Connect(function(sucess) FishingGui:Destroy() DBA = true if DBA == false then if sucess == true then print("yay") else print("uSuck") end DBA = true end local bv = script.Parent.Pointer:FindFirstChild("BodyVelocity") if bv then bv:Destroy() end script.Parent.isThrown.Value = false script.Parent.Pointer.CanCollide = false local length = (mouse.p - rootpart.Position).Magnitude attach(script.Parent.Pointer, script.Parent.Device, CFrame.new(0,0,0)) script.Parent.Pointer.RopeConstraint.Length = 1 script.Parent.Reeling.Value = false end) end if not RemoteThrow then RemoteThrow = Instance.new("RemoteEvent", ReplicatedStorage) RemoteThrow.Name = "RemoteThrow" end if not RemoteRetract then RemoteRetract = Instance.new("RemoteEvent", ReplicatedStorage) RemoteRetract.Name = "RemoteRetract" end if not RemoteSendOwnerName then RemoteSendOwnerName = Instance.new("RemoteEvent", ReplicatedStorage) RemoteSendOwnerName.Name = "RemoteSendOwnerName" end local Pointer = script.Parent.Pointer script.Parent.Pointer.Touched:Connect(function(Part) onGround = true end) script.Parent.Pointer.TouchEnded:Connect(function() onGround = false end) function attach(source, destination, offset) local weld = Instance.new("WeldConstraint", destination) weld.Name = "thing" source.CFrame = destination.CFrame * offset weld.Part0 = source weld.Part1 = destination end attach(script.Parent.Pointer, script.Parent.Device, CFrame.new(0,0,0)) local function onThrow(player, mouse, rootpart, Maxlength, speed, LP) CreateFishHandler() if player.Name == script.Parent.Parent.Name then if not script.Parent.isThrown.Value then script.Parent.isThrown.Value = true script.Parent.Handle.woosh.Volume = .25 if not onGround then script.Parent.Handle.woosh:Play() end local WeldConstraint = script.Parent.Device:FindFirstChild("thing") if WeldConstraint then WeldConstraint:Destroy() end local factor = 1 local direction = mouse.p - script.Parent.Pointer.Position local length = direction.Magnitude direction = direction.Unit local result = (direction + rootpart.UpVector).Unit local BodyVelocity = Instance.new("BodyVelocity", Pointer) length = math.clamp(length, 1, Maxlength) Pointer.RopeConstraint.Length = length BodyVelocity.P = 10e10 BodyVelocity.MaxForce = Vector3.new(10e10, 10e10,10e10) BodyVelocity.Velocity = factor * speed * result Pointer.CanCollide = true wait(length / speed) BodyVelocity:Destroy() end end end local function onRetract(player, mouse, rootpart, LP) if script.Parent.Reeling.Value == false then if player.Name == script.Parent.Parent.Name then if script.Parent.isThrown.Value then if script.Parent.IsFish.Value == false then Pointer.CanCollide = false script.Parent:WaitForChild("FishHandler"):Destroy() local bv = script.Parent.Pointer:FindFirstChild("BodyVelocity") if bv then bv:Destroy() end script.Parent.isThrown.Value = false local length = (mouse.p - rootpart.Position).Magnitude attach(script.Parent.Pointer, script.Parent.Device, CFrame.new(0,0,0)) script.Parent.Pointer.RopeConstraint.Length = 1 else FishFunc(player, mouse, rootpart, LP) end end end end end RemoteThrow.OnServerEvent:Connect(onThrow) RemoteRetract.OnServerEvent:Connect(onRetract)