So im trying to make a soccer game and make it so if the ball touches the player the ball follows the player and if the ball touches a part other then parts named “Floor” and the humanoid the player cant pickup the ball for 1 second and the ball rolls, But the problem with this script is that the ball does not follow the player. Everything else works, here’s my script.
local players = game:GetService("Players")
local ball = script.Parent
local currentPlayer = nil
ball.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and player ~= currentPlayer and hit.Parent:FindFirstChild("Humanoid") then
currentPlayer = player
ball.Anchored = false
ball.CanCollide = true
ball.Velocity = Vector3.new(0,0,0)
ball.Position = currentPlayer.Character.HumanoidRootPart.Position + Vector3.new(0,0,1)
wait(1)
ball.CanCollide = false
ball.Anchored = true
end
end)