Hi, I’m trying to make a fishing system, right now I just want it so when they click on it itll set the fishings rods attachtment to where they clicked and play a splash animation, it seems to be playing the splash animation at the correct position, but the attatchment is far away and inaccurate? Heres a video: Watch Fishing Bug | Streamable And heres my code:
local FishingServer = {}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FishingClickEvent = ReplicatedStorage.Remotes:WaitForChild("FishingClickEvent")
local FishingDisableControls = ReplicatedStorage.Remotes:WaitForChild("FishingDisableControls")
local FishingEnableControls = ReplicatedStorage.Remotes:WaitForChild("FishingEnableControls")
local FishingResetPosition = ReplicatedStorage.Remotes:WaitForChild("FishingResetPosition")
local MAX_CLICK_DISTANCE = 50
local DEFAULT_END_POSITION = Vector3.new(-0.265, -1.41, 0.668)
local WaterFoam = game.Workspace.Water.WaterFoam
local Splash = WaterFoam.Splash
local Ts = game:GetService('TweenService')
local T1 = Ts:Create(Splash, TweenInfo.new(0.5, Enum.EasingStyle.Linear), {Size = Vector3.new(10, 1, 9.167)})
local function RunWater()
Splash.Attachment.Splash:Emit(1)
Splash.Attachment.Mist:Emit(1)
end
local function RunEffect(Pos)
Splash.Size = Vector3.new(6, 1, 5.5)
Splash.Position = Vector3.new(Pos.X, Splash.Position.Y, Pos.Z)
coroutine.wrap(RunWater)()
T1:Play()
Splash.Attachment.Splash2:Emit(1)
end
function FishingServer.OnFishingClick(player, targetName, clickPosition)
if targetName == "FishingSpot" then
local character = player.Character
local distance = (clickPosition - character.PrimaryPart.Position).Magnitude
if distance <= MAX_CLICK_DISTANCE then
local tool = character:FindFirstChild("Fishing Rod")
if tool then
local handle = tool:FindFirstChild("Handle")
if handle then
local endPart = handle:FindFirstChild("End")
if endPart then
endPart.Position = clickPosition
RunEffect(clickPosition)
print("Fishing rod handle moved to position:", clickPosition)
FishingDisableControls:FireClient(player)
else
warn("Fishing Rod handle does not have an 'End' part")
end
else
warn("Fishing Rod does not have a 'Handle'")
end
else
warn("Player does not have a Fishing Rod")
end
else
print("Click is too far")
end
end
end
function FishingServer.OnResetPosition(player)
local character = player.Character
local tool = character and character:FindFirstChild("Fishing Rod")
if tool then
local handle = tool:FindFirstChild("Handle")
if handle then
local endPart = handle:FindFirstChild("End")
if endPart then
endPart.Position = DEFAULT_END_POSITION
print("Fishing rod handle reset to default position:", endPart.Position)
else
warn("Fishing Rod handle does not have an 'End' part")
end
else
warn("Fishing Rod does not have a 'Handle'")
end
else
warn("Player does not have a Fishing Rod")
end
FishingEnableControls:FireClient(player)
end
function FishingServer.Init()
FishingClickEvent.OnServerEvent:Connect(function(player, targetName, clickPosition)
FishingServer.OnFishingClick(player, targetName, clickPosition)
end)
FishingResetPosition.OnServerEvent:Connect(function(player)
FishingServer.OnResetPosition(player)
end)
end
return FishingServer