Hi. I am making a fishing quest for my game, so I made a fishing rod for testing so I could add it into my game, but it isn’t working as it should. Here’s the video: https://streamable.com/l7uord
And here’s the code:
local FishingRod = script.Parent;
local Hook = FishingRod:WaitForChild('Hook')
local debounce = false
local function on_Activated()
if not debounce then
debounce = true
else
return;
end
local rope = Instance.new("RopeConstraint", Hook);
local Lure = Instance.new("Part", workspace);
Lure.Size = Vector3.new(.2, .2, .2)
Lure.CFrame = Hook.CFrame;
rope.Visible = true
rope.Length = (game.Players.LocalPlayer:GetMouse().Hit.p - Lure.CFrame.p).magnitude;
rope.Thickness = 0.1
rope.Restitution = 6
local attachment1 = Instance.new("Attachment")
local velo = Instance.new("BodyVelocity", Lure);
velo.MaxForce = Vector3.new(1,1,1) * math.huge
velo.P = 20
velo.Velocity = game.Players.LocalPlayer:GetMouse().Hit.lookVector * 50;
attachment1.Parent = Lure
rope.Attachment0 = Hook:FindFirstChild("Attachment")
local att0 = Hook:FindFirstChild("Attachment")
rope.Attachment1 = attachment1
attachment1.Position += Vector3.new(2.5,0, 0);
wait(0.5)
velo:Destroy()
wait(5)
debounce = false
rope:Destroy()
Lure:Destroy()
attachment1:Destroy()
end
FishingRod.Activated:Connect(on_Activated);
You have not specified what you really wanted it to do, I can only assume that you don’t want it to go directly to the mouse but to fall short.
The best thing for this would be to set a max distance for the rod. When using the rod you would want to fire it in the direction of the mouse. Using the same kind of script only set the position to be a fraction of the distance and then find the point of ground below. This way in order to throw the lure further they would have to aim further out and this would also mean that they could aim upwards to throw the lure.
That is because of the length, You would need to calculate the how much slack to give the rope. When you shorten the rope there will be less slack so it wont go into the ground.
When you set the length of a rope to be the magnitude it will be the furthest possible point, However the lure isn’t quite as far as that resulting in slack. It isnt a major issue, You will just need to take away a fraction of the ropes length. Play around with it until you are happy with the result and use that factor. This will take the distance into account so it will give better results.