I mean, is it possible to make the ball travel the same distance but at a lower speed?
here is all code:
Client:
uis.InputBegan:Connect(function(Input,GPE)
if not GPE then
if Input.UserInputType == Enum.UserInputType.MouseButton2 then
holded = true
ui.Visible = true
punchPower = 1
while true do
punchPower += 1
gui.Size = UDim2.new(gui.Size.X.Scale + 0.01,0,1,0)
task.wait(0.001)
if punchPower == 100 or holded == false then
break
end
end
end
end
end)
uis.InputEnded:Connect(function(Input,GPE)
if not GPE then
if Input.UserInputType == Enum.UserInputType.MouseButton2 then
holded = false
local cameraDirection = game.Workspace.CurrentCamera.CFrame.LookVector
ui.Visible = false
gui.Size = UDim2.new(0,0,1,0)
if game:GetService("UserInputService").MouseBehavior == Enum.MouseBehavior.LockCenter then
remote:FireServer(punchPower,cameraDirection,"yes")
else
remote:FireServer(punchPower,cameraDirection,"no")
end
punchPower = 1
end
end
end)
remote.OnClientEvent:Connect(function(ball,power,direction)
ball:ApplyImpulse(direction)
end)
Server:
remote.OnServerEvent:Connect(function(player,Power,dir,arg)
local ball = game.Workspace:FindFirstChild("Football")
local character = player.Character or player.CharacterAdded:Wait()
local HRP = character:FindFirstChild("HumanoidRootPart")
--Check if ball near to player
local extents = 6 * Vector3.one -- Is Radius
local region = Region3.new(HRP.Position - extents, HRP.Position + extents)
local np = workspace:FindPartsInRegion3WithIgnoreList(region,{character,game.workspace.Camera}) --Save nearby objects in a list
for _, p in np do
if p == ball then
if ball.Owner.Value == player.Name or ball.Owner.Value == "Neutral" then
if ball:FindFirstChild("BodyPosition") then
ball:FindFirstChild("BodyPosition"):Destroy()
elseif ball:FindFirstChild("LinearVelocity") then
ball:FindFirstChild("LinearVelocity"):Destroy()
end
ball:SetNetworkOwner(player)
local direction
local factor
if Power <= 30 then
factor = 5
else
factor = 3.75
end
if arg == "yes" then
direction = dir * Power * factor + Vector3.new(0,game.Workspace.Gravity * 0.2,0) / 5
else
direction = HRP.CFrame.LookVector * Power * factor
end
remote:FireAllClients(ball,Power,direction)
end
end
end
end)