Make sure you set the network ownership of the ball to the player, make the character PlatformStanding, and control the movement of the ball on the client.
What you could do is detect when they keys WASD are pressed, then apply some force to your BodyVelocity or whatever you plan to use. You can use the camera’s LookVector to tell which way you should be going.
game:GetService('Players').PlayerAdded:Connect(function(Player)
local GiveBall = function()
local Ball = Instance.new("Part");
Ball.Name = "Ball"
local Weld = Instance.new("Weld");
Weld.Name = "Giver"
local Character = Player.Character or Player.CharacterAdded:Wait();
local Humanoid = Character:WaitForChild('Humanoid');
Weld.Parent = Ball;
Weld.Part1 = Ball;
Weld.Part0 = Character.HumanoidRootPart;
Ball.Parent = Character;
Ball.Anchored = false;
Ball.Shape = Enum.PartType.Ball;
Ball.Size = Player.Character.HumanoidRootPart.Size + Vector3.new(5, 5, 5);
Ball.Material = Enum.Material.ForceField;
Ball.CFrame = Player.Character.HumanoidRootPart.CFrame;
Ball.Color = Color3.new(0, 0, 1);
end
GiveBall();
Player.CharacterAdded:Connect(function()
GiveBall();
end)
end)
Local Script:
local Player = game:GetService('Players').LocalPlayer;
local InputService = game:GetService('UserInputService');
local Camera = workspace.CurrentCamera;
local Settings = {
Speed = 30,
JumpPower = 60,
Size = Vector3.new(5, 5, 5)
}
local Character = Player.Character or Player.CharacterAdded:Wait();
local Humanoid = Character:WaitForChild('Humanoid');
local RayParams = RaycastParams.new();
local Ball = Character:WaitForChild('Ball');
local Connection;
Camera.CameraSubject = Ball
RayParams.FilterType = Enum.RaycastFilterType.Blacklist;
RayParams.FilterDescendantsInstances = {Character};
for _, v in next, Player.Character:GetChildren() do
if v:IsA('BasePart') and v ~= Ball then
v.Massless = true;
v.CanCollide = false;
end
end
Humanoid.Died:Connect(function() Connection:Disconnect() end);
Connection = game:GetService('RunService').RenderStepped:Connect(function(delta)
Humanoid.PlatformStand = true;
Ball.CanCollide = true;
if InputService:IsKeyDown('W') then
Ball.RotVelocity -= Camera.CFrame.RightVector * delta * Settings.Speed
end
if InputService:IsKeyDown('A') then
Ball.RotVelocity -= Camera.CFrame.LookVector * delta * Settings.Speed
end
if InputService:IsKeyDown('S') then
Ball.RotVelocity += Camera.CFrame.RightVector * delta * Settings.Speed
end
if InputService:IsKeyDown('D') then
Ball.RotVelocity += Camera.CFrame.LookVector * delta * Settings.Speed
end
end)
InputService.JumpRequest:Connect(function()
if workspace:Raycast(Ball.Position, Vector3.new(0, -((Ball.Size.Y / 2) + 0.3), 0), RayParams) then
Ball.Velocity = Ball.Velocity + Vector3.new(0, Settings.JumpPower, 0)
end
end)