Soccer Shooting system

You can write your topic however you want, but you need to answer these questions:

  1. I am trying to make that when the ball is clicked it shoots depending on click duration

  2. I have looked everywhere in the devforum and documentation but i am very confused
    i dont know what to use for this

3 Likes

get the time difference between when you first initiated the click and when you let go of the click using os.clock, you will use this time difference for the kick duration. then you can multiply the difference to any value to make the kick power stronger.

1 Like

but how do i make it go to the aim in the air?

1 Like

time difference multiplied to the camera lookvector multiplied to the additional multiplier value.

1 Like

i mean do i use something like body force or linear force because this is wath i find confusing .

1 Like

you can use ApplyImpulse() its built for forces like kicking a ball upwards

1 Like

OK, i am gonna try using applyimpulse()

1 Like

BasePart | Roblox Creator Documentation , the dev doc dosent have exemples do you have one?

part:ApplyImpulse(Vector3)

Oh ok and how to change the power of the force?

by changing the vector3 value, and using my advice from the beginnig

1 Like

so i now tried multiple things and a thing i have donae dosent even works

local character = script.Parent
local UIs = game:GetService("UserInputService")
local kickpo = 500
UIs.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		print("inputBegan")
		local startime =  tick()
		UIs.InputEnded:Connect(function(input)
			print("inputended")
			if input.UserInputType == Enum.UserInputType.MouseButton2 then
				
				local endtime = tick()
				local duration = endtime - startime
				local kickpower = kickpo * duration
				local rootpart = character:FindFirstChild("HumanoidRootPart")
				if rootpart then
					local bodyforce = Instance.new("VectorForce")
					bodyforce.Force =  Vector3.new(0, kickpower, 0)
					bodyforce.Parent = rootpart
					wait(duration/2)
					bodyforce:Destroy()
				end
			end
		end)
	end
end)

hi are you still on this post. Because i might have a solution

You can use a RemoteEvent to find the time a mouse is clicked; this can be done by firing the event when the mouse is pressed and is released. The duration can then be multiplied by a factor/vector3 value, and then use the vector3 value in the :ApplyImpulse() function to apply an impulse to the ball. This is true if the ball is a part. Rather than :ApplyImpulse, you could also use a bodyForce or somethin like a bodyVelocity.

I found the solution i used a bezier curve to replicate the kick effect and it is more controlable than using forces i also used a remote event ,getmouse() and userinputservice .

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.