Hello, I have a fishing rod that shoots a ball to a direction the player clicks. Achieved by using a local script to “fireServer” so that the server script will create a ball that shoots with the direction data provided by the client.
Problem:
The client side is somehow delayed despite the ball being controlled by the server. When the ball hits the ground, it stopped. But the client shows the ball stopping mid-air because the client side is slow. What can I do to fix it ?
Server:
Client:
Here is the script on the server:
local function createBall(position, direction, player, Tip)
local ball = Instance.new("Part")
ball.Name = "ball"
ball.Shape = Enum.PartType.Ball
ball.Size = Vector3.new(0.3, 0.3, 0.3)
ball.Position = position
ball.Material = Enum.Material.Neon
ball.Anchored = false
ball.CanCollide = false
ball.Massless = true
ball.Parent = Workspace
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Velocity = direction * Speed -- Slow descent
BodyVelocity.Parent = ball
local Attatchment = Instance.new("Attachment")
Attatchment.Parent = ball
local Beam = Instance.new("Beam")
Beam.Name = "Line"
Beam.Attachment0 = Attatchment
Beam.Attachment1 = Tip.Attachment
Beam.Width0 = 0.2
Beam.Width1 = 0.2
Beam.Color = ColorSequence.new(Color3.new(0,0,0))
Beam.FaceCamera = true
Beam.Parent = ball
local tag = Instance.new("ObjectValue")
tag.Name = "Tag"
tag.Value = player
tag.Parent = ball
local function stopBall()
ball.Anchored = true
ball.Velocity = Vector3.new(0, 0, 0)
end
ball.Touched:Connect(function(hit)
if hit:IsA("BasePart") and hit.CanCollide and hit.Parent ~= player.Character then
stopBall()
end
end)
local connection
connection = RunService.Stepped:Connect(function()
if ball.Position.Y <= 0 then
stopBall()
connection:Disconnect()
end
end)
end
Please help