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 want to make a working dodgeball in roblox studio that is able to be thrown in the direction of a mouse click. -
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. -
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?