Hi. I am making a soccer ball for my game, but the only problem is is that physics are kind of sucffed and powers are random. The duration is basically how long the mouse is held for on the client, then a remote event fires and a bodyforce is created.
I am trying to make it so the ball stays in the air like you are doing a kick up for a bit then drops back down on the floor, but that only works if you hold the mouse down for more than 1 second.
Script:
RemoteEvent:Connect(function(Player, Ball, Duration)
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local Distance = HumanoidRootPart.Position.Magnitude - Ball.Position.Magnitude
if Distance > 1 then return end
if not Torso:FindFirstChild("BallWeld") then return end
local BodyForce = Instance.new("BodyForce")
BodyForce.Force = Torso.CFrame.LookVector * 500 * Duration + Vector3.new(0, 1100*Duration, 0)
BodyForce.Name = Player.Name
BodyForce.Parent = Ball
Sound:Play()
Debris:AddItem(BodyForce , 0.45)
for _, v in pairs(Torso:GetDescendants()) do
if v:IsA("Weld") and v.Name == "BallWeld" then
v:Destroy()
end
end
end)
Any help would be appriciated, thanks!