You can write your topic however you want, but you need to answer these questions:
-
I want to be able to make a football system similar to the popular game “Blue Lock: Rivals”
-
I have made a similar system, but it is pretty bare bones and I don’t think this is the best way it could be done at all.
Mine:
Theirs:
- I have tried welding the ball to the player that the ball’s attribute said last touched the ball with runservice checking every frame.
script in ball:
local CharWeld = ball.CharWeld
local hitbox = ball:WaitForChild("Hitbox")
local runserv = game:GetService("RunService")
ball.CollisionGroup = "Ball"
ball:SetAttribute("PlayerHoldingBall", nil)
local function hitboxTouched(part)
if part.Name == "HumanoidRootPart" and ball:GetAttribute("PlayerHoldingBall") == nil then
ball:SetAttribute("PlayerHoldingBall", part.Parent.Name)
end
end
local function plrPossess()
if ball:GetAttribute("PlayerHoldingBall") ~= nil then
CharWeld.Part0 = workspace[ball:GetAttribute("PlayerHoldingBall")].HumanoidRootPart
ball.CanCollide = false
end
end
hitbox.Touched:Connect(hitboxTouched)
runserv.Heartbeat:Connect(plrPossess)
other scripts don’t really matter as they just handle collisions