Hello I made a topic about this already: Setting network ownership of a ball smoothly
I thought it had fixed the bug but no; the bug still happens randomly to certain players. When they leave and rejoin, the bug STILL occurs. I have no idea why this is happening. I decided to split the shooting code into two, so that the server would handle the network ownership and status effects and the client would handle the shooting physics.
The server:
local ball = workspace.TestBall
create("Unrecievable",ball,0.5)
ball.CanCollide = true
ball.Taken.Value = false
ball:SetNetworkOwner(player)
if Character:FindFirstChild("HasBall") then
Character.HasBall:Destroy()
end
if Character.HumanoidRootPart:FindFirstChild("BallPossession") then
Character.HumanoidRootPart.BallPossession:Destroy()
end
if Character:FindFirstChild("OwnerCircle") then
Character.OwnerCircle.Transparency = 1
end
if Character:FindFirstChild("OwnHL") then
Character.OwnHL:Destroy()
end
ball:SetNetworkOwner(player)
SoundManager.PlayKick(Character.HumanoidRootPart)
EffectsManager.Kick(Character)
The Client:
local ball = workspace.TestBall
create("Unrecievable", ball, 0.6)
ball.CanCollide = true
create("normalsho",Character,0.3)
if Character:FindFirstChild("HasBall") then
Character.HasBall:Destroy()
end
if Character.HumanoidRootPart:FindFirstChild("BallPossession") then
Character.HumanoidRootPart.BallPossession:Destroy()
end
local shootingStat = player.stats:GetAttribute("Shooting")
local archetype = player.stats:GetAttribute("Archetype")
if archetype == "Finisher" then
shootingStat += 5
end
local maxShooting = 95
local softCap = 85
local baseErrorAngleMax = 10
local baseErrorAngleMin = 0.1
local baseVerticalErrorMax = 10
local baseVerticalErrorMin = 1
local effectiveStat = math.clamp(shootingStat, 40, maxShooting)
local scale
if effectiveStat <= softCap then
scale = (effectiveStat - 40) / (softCap - 40)
else
scale = 1 + ((effectiveStat - softCap) / (maxShooting - softCap)) * 0.2
end
local errorAngle = baseErrorAngleMax - (baseErrorAngleMax - baseErrorAngleMin) * math.clamp(scale, 0, 1.2)
local verticalError = baseVerticalErrorMax - (baseVerticalErrorMax - baseVerticalErrorMin) * math.clamp(scale, 0, 1.2)
local basePowerBoost = 1.1
local finisherPowerBoost = (archetype == "Finisher") and 1.05 or 1
local finalPower = power * basePowerBoost * finisherPowerBoost
local randomAngle = math.rad((math.random() * 2 - 1) * errorAngle)
local deviationCFrame = CFrame.fromAxisAngle(Vector3.new(0, 1, 0), randomAngle)
local modifiedDirection = deviationCFrame:VectorToWorldSpace(mousepos)
local force = modifiedDirection * finalPower
local upwardForce = ((finalPower - 60) / 50 * 10) + verticalError
local totalVelocity = force + Vector3.new(0, upwardForce, 0)
local attachment = Instance.new("Attachment")
attachment.Parent = ball
local linearVelocity = Instance.new("LinearVelocity")
linearVelocity.Attachment0 = attachment
linearVelocity.VectorVelocity = totalVelocity
linearVelocity.MaxForce = math.huge
linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
linearVelocity.Parent = ball
game.Debris:AddItem(linearVelocity,0.5)
game.Debris:AddItem(attachment,0.5)
create("SlowDown", Character, 0.1)
create("CantShoot", Character, 0.3)
In this video, me and my friend “Gerald” can consistently kick the ball and it will move accordingly, however my other friend tries to kick it and it goes nowhere consistently, even after he left and rejoined. Nothing shows up in the console either.