Recently i finished my kick power bar for my football game, but the problem is that i cant find any good solution or way to make a shot system. Bascially i tried to use every physic components that are in roblox studio engine, i tried to combine it with customPhysicalSettings but nothing works as i expected, ball was going after player very slow or it didnt looked like an actual kick.
So my idea is to make it with bezier Curve and i need opinion and little example if its good idea or not idea
local event = game.ReplicatedStorage.PowerUI
local RunService = game:GetService('RunService')
local RepStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local debris = game:GetService("Debris")
local connection
local deb = false
local debTime = 2.5
local powerChargeAmount = 2
local maxPower = false
local ballMass = 0.438
local fallFriction = 0.3
function Hitboxes(humanoidRootPart: Part, power, cameraHeight)
local size = Vector3.new(5.5, 5, 5.5)
local pointer: Part = RepStorage["Camera Pointer"]:Clone()
local hrpPosition = humanoidRootPart.CFrame
local hrpLoopVec = humanoidRootPart.CFrame.LookVector
local shotPos = Vector3.new(humanoidRootPart.CFrame.LookVector.X, cameraHeight, humanoidRootPart.CFrame.LookVector.Z)
local results = workspace:GetPartBoundsInBox(humanoidRootPart.CFrame, size, nil)
for i, v in results do
if v.Parent.Name == "Soccer Ball" and v:IsA("MeshPart") then
//Place on shoot system
end
end
end
function ChargePower(plr, inputHeld, cameraView)
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:FindFirstChild("HumanoidRootPart")
local torso = char:WaitForChild("Torso")
local powerVal = torso["Power Bar"].Power
if not inputHeld then
Hitboxes(hrp, powerVal.Value, cameraView)
powerVal.Value = 0
event:FireClient(plr, powerVal.Value)
return connection:Disconnect()
end
connection = RunService.Heartbeat:Connect(function(dt)
--Checks if power didnt reached 100
if powerVal.Value ~= 100 and not maxPower then
powerVal.Value += powerChargeAmount
else
--When power reaches 100 it goes down to 0
if powerVal.Value <= 0 then
maxPower = false
event:FireClient(plr, powerVal.Value, "out of power")
return connection:Disconnect()
end
maxPower = true
powerVal.Value -= powerChargeAmount
end
event:FireClient(plr, powerVal.Value)
end)
end
event.OnServerEvent:Connect(ChargePower)