You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I am making a soccer game. When the ball is midair, you can jump and if you touch the ball hitbox, the ball is sent forward and up in your direction.
Currently, because I am using the touched event even though I immediately turn a variable so the ball can’t be headered, the ball is still headered up to several times. I also want the force/direction of the ball to range from where you hit the hitbox. E.g middle of hitbox == straight up, from behind == forward, and so on, so if the ball is moving slower/faster than you it doesn’t go past you or behind you after a few jumps.
- What is the issue? Include screenshots / videos if possible!
I am not sure how to go about the touched issue, aside from maybe using a getpartsinpart while loop which is inefficient and probably won’t work because of a thing in my script, and I’m not sure how’d I go about sending a part opposite from where it was hit.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried searching on the forum and experimenting.
--script
BALL.HeaderHitbox.Touched:Connect(function(hit)
if not hit.Parent or hit.Parent and hit.Parent == workspace then
return
end
if BALL.InPossession.Value == false and hit.Parent:FindFirstChildOfClass("Humanoid") and BALL.CanSteal.Value == true then
if BALL.Position.Y >= 3 and hit.Parent:FindFirstChild("Humanoid").FloorMaterial == Enum.Material.Air then
game.ReplicatedStorage.Sounds.Header:Play()
BALL.CanSteal.Value = false
BALL.AssemblyLinearVelocity = Vector3.new(hit.Parent.HumanoidRootPart.CFrame.LookVector.X, 2.5, hit.Parent.HumanoidRootPart.CFrame.LookVector.Z) * 25
task.wait(0.1)
BALL.CanSteal.Value = true
end
end
end)
--client
(part of inputconnected)
elseif inp.KeyCode == Enum.KeyCode.Space then
if not player.Character:FindFirstChild("Ball") then
return
end
player.Character.Animate.fall.FallAnim.AnimationId = "rbxassetid://90181425663093"
player.Character.Animate.jump.JumpAnim.AnimationId = "rbxassetid://82089533067053"
player.Character.Humanoid.FreeFalling:Connect(function(active)
if not active then
player.Character.Animate.fall.FallAnim.AnimationId = "rbxassetid://126983242151101"
player.Character.Animate.jump.JumpAnim.AnimationId = "rbxassetid://74861334091368"
end
end)
game.ReplicatedStorage.RemoteFunctions.RainbowFlickFunction:InvokeServer(player.Character.HumanoidRootPart.CFrame.LookVector)