Help making a dodgeball

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

  1. What do you want to achieve? Keep it simple and clear!
    I want to make a working dodgeball in roblox studio that is able to be thrown in the direction of a mouse click.
  2. What is the issue? Include screenshots / videos if possible!
    I am having trouble getting the throwing aspect down. Currently, I am using vector force to throw the ball, but the ball seems to roll only on the ground and rolls the wrong way. I am also not sure how I can make the ball move in the direction of the mouse click which I need help on. I used AlvinBlox’s quick gun tutorial to try and get the mouse hit, but I couldn’t fully apply it to my dodgeball.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked on the Developer Hub for support of a dodgeball and I found a topic that said to use vector force which I did. Vector force is still new to me though, so I looked it up and applied some of the properties to my script. The ball though doesn’t get thrown in the air, goes backwards, and isn’t working how I want it to.

Script inside ball

local equipped = script.Parent.Equipped
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if equipped.Value == false then
			equipped.Value = true
			local character = hit.Parent
			print("True")
			script.Parent.Position = character["Right Arm"].Position
			local ballweld = game.ServerStorage.Dodgeball:Clone()
			ballweld.Part0 = character["Right Arm"]
			ballweld.Part1 = script.Parent
			ballweld.Parent = script.Parent
			script.Parent.Parent = character
		end
	end
end)

Local script inside starter player scripts

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Button1Down:Connect(function()
	game.ReplicatedStorage.Fire:FireServer(player, mouse.Hit.p)
end)

Server script inside server script storage

game.ReplicatedStorage.Fire.OnServerEvent:Connect(function(player, mousepos)
	if player.Character:FindFirstChild("Dodgeball") then
		player.Character.Dodgeball.Dodgeball:Destroy()
		player.Character.Dodgeball:WaitForChild("PlayerFired").Value = player.Name
		player.Character.Dodgeball.Parent = workspace
		if game.Workspace.Dodgeball:WaitForChild("PlayerFired").Value == player.Name then
			local balltoapplyforce = game.Workspace.Dodgeball
			local vectorforce = Instance.new("VectorForce", balltoapplyforce)
			vectorforce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
			vectorforce.ApplyAtCenterOfMass = true
			vectorforce.Force = Vector3.new(100,100,100)
			local attachment = Instance.new("Attachment")
			vectorforce.Attachment0 = attachment
			attachment.Parent = balltoapplyforce
			wait(2)
			vectorforce:Destroy()
			attachment:Destroy()
			print("Successfully destroyed")
			balltoapplyforce:WaitForChild("Equipped").Value = false
			print("yes")
		end
	end
end)

How can I make it so that the ball is thrown into the air and how can I make it so that it is thrown in the direction of the player’s mouse?

2 Likes

Looks like you need to set the VectorForce to Enum.ActuatorRelativeTo.World
And use the Vector3 got from the client’s mouse click to give it to the Force, so the Part will go to that coordinate. (well Im not sure about the coordinate… Probably the Vector should be translated… I never used VectorForce before… I think BodyMovers can do a better job)

If you use Attachment mode, 0 or 1, the direction could change if the Part rotates (attach0), maybe its a “desirable” effect if you want it to “bounce” but it wont look like a bounce, more like a rocket going always forward… Reorienting the Attachment (attch1) and changing its position could make a bounce effect… but, too complicated just to simulate a bouncing.

And I dont know how u can keep the ball floating on air… Maybe add a BodyMover…

Which leads me to a total different approach, why not using BodyMovers instead of the VectorForce?

2 Likes