Hi Im CTG, I Need Help With My Fishing Rod, When I Unequip FishingRod And Equip Again It Will Create More 1 Ball And If Repeat That It Will Create More
Also When I Got The Fish, And Equip Again It Will Cant Fishing Again
local isCasted = script.Parent.Catch
local tip = script.Parent.FishingRod.Tip
local percentages = {
Common = 60,
Uncommon = 30,
Rare = 10,
Epic = 5,
}
local total = 0
for i, v in pairs(percentages) do
total += v
end
local function getRandomItem()
local r = math.random(1, total)
local add = 0
for item, v in pairs(percentages) do
if r > add and r <= add + v then
return item
end
add += v
end
end
function getVelocity(player, mousePosition)
local time = 0.5;
local gravity = Vector3.new(0, -game.Workspace.Gravity, 0);
local initialPosition = player.Character.HumanoidRootPart.CFrame * Vector3.new(0, 8, -1)
local velocity = (mousePosition - initialPosition - 0.5*gravity*time*time)/time;
return velocity
end
function createLure(player, mousePosition)
local lure = Instance.new('Part')
lure.BrickColor = BrickColor.new('Light orange')
lure.Material = "Neon"
lure.CanCollide = true
lure.Shape = 'Ball'
lure.Size = Vector3.new(0.1, 0.1, 0.1)
lure.CustomPhysicalProperties = PhysicalProperties.new(1, 0, 0, 1, 1)
lure.Parent = script.Parent
lure.CFrame = player.Character.HumanoidRootPart.CFrame + Vector3.new(0, 8, -1)
lure.Velocity = getVelocity(player, mousePosition)
lure.Name = "Ball"
return lure
end
function createRope(lure, mousePosition)
local Attachment = Instance.new('Attachment')
local mag = (mousePosition - script.Parent.FishingRod.Tip.Position).Magnitude
local rope = Instance.new('RopeConstraint')
rope.Thickness = 0.05
rope.Visible = true
rope.Length = math.clamp(mag, 10,40)
rope.Attachment0 = tip.Attachment
rope.Attachment1 = Attachment
rope.Name = "Rope"
rope.Restitution = 0
rope.Parent = lure
Attachment.Parent = lure
return rope
end
script.Parent.GetMouse.OnServerEvent:Connect(function(player, lookVector, mousePosition)
if script.Parent:FindFirstChild("Ball") and isCasted.Value == true and script.Parent.Ball:FindFirstChild("Sparkles") then
print("Work")
player.Character.Humanoid:UnequipTools()
local Player = player
local multi = Player.Stats.Multiplier
local money = Player.Stats.Money
local reb = Player.Stats.Rebirth
local touch = Player.leaderstats.Touch
local exp = Player.Stats.Exp
local qp = Player.Stats.QuestPoint
local random = getRandomItem()
if random == "Common" then
money.Value += 1
game:GetService("ReplicatedStorage").Accoument:FireAllClients("Common")
elseif random == "Uncommon" then
money.Value += 10
game:GetService("ReplicatedStorage").Accoument:FireAllClients("Uncommon")
elseif random == "Rare" then
money.Value += 100
game:GetService("ReplicatedStorage").Accoument:FireAllClients("Rare")
elseif random == "Epic" then
reb.Value += 1
game:GetService("ReplicatedStorage").Accoument:FireAllClients("Epic")
end
for i, Ball in pairs(script.Parent:GetChildren()) do
if Ball.Name == "Ball" then
Ball:Destroy()
end
end
script.Parent.Lure:Destroy()
return
elseif not script.Parent:FindFirstChild("Ball") then
if lookVector then
warn("Fish")
if not isCasted.Value then
wait(0.1)
warn("Fish")
isCasted.Value = true
local lure = createLure(player, mousePosition)
local rope = createRope(lure, mousePosition)
game:GetService("ServerStorage").Lure:Clone().Parent = lure
local bodyGyro = Instance.new("BodyGyro")
bodyGyro.Parent = lure
while true do
wait()
bodyGyro.CFrame = lure.CFrame
end
elseif isCasted.Value and script.Parent:FindFirstChild("Ball") and not script.Parent.Ball:FindFirstChild("Sparkles") then
player.Character.Humanoid:UnequipTools()
end
else
isCasted.Value = false
end
end
end)
script.Parent.Unequip.OnServerEvent:Connect(function(player)
if isCasted.Value and script.Parent:FindFirstChild("Ball") and not script.Parent.Ball:FindFirstChild("Sparkles") then
for i, Ball in pairs(script.Parent:GetChildren()) do
if Ball.Name == "Ball" then
Ball:Destroy()
print(Ball)
end
end
warn("Fish")
isCasted.Value = false
if script.Parent:FindFirstChild("Ball") then
script.Parent.Ball:Destroy()
end
if script.Parent:FindFirstChild("Ball") and script.Parent.Lure:FindFirstChild("Rope") then
script.Parent:WaitForChild("Ball").Rope:Destroy()
script.Parent:WaitForChild("Ball"):Destroy()
if script.Parent:FindFirstChild("Ball") then
script.Parent.Ball:Destroy()
end
end
end
end)