How do I make a curved projectile? Scripting support

I am making a remote event that spawns a spinner the goes towards the mouse. The script below works and is bug free currently. I need help with making this event spawn the spinner and make it take a curved path towards the enemy. How would I do that? Any tips?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("TapRequest")

remoteEvent.OnServerEvent:Connect(function(player, tapPosition)
	local spinnerTemplate = ReplicatedStorage:WaitForChild("spinner")
	local db = false
	if db == false then
		db = true
	
	local data = player:WaitForChild("MatchData")
	local DMGM = data.DmgM
	local CoolReduction = data.CoolReduction
	local spinners = data.SpinnersLeft
	local espinners = data.ExtraSpinners
	local SSM = data.SpinnerSpeedMult
		
		local data = player:WaitForChild("DataSave")
		local color = data.Color
		local shape = data.Shape
		local material = data.Material
		local trail = data.Trail



		-- Update the spinner's properties based on the player's customization data
	local hum = player.Character.Humanoid
		if spinners.Value > 0 then 
			local newSpinner = spinnerTemplate:Clone()
			if color.Value == 0 then
				newSpinner.BrickColor = BrickColor.new("Bright red")
			elseif color.Value == 1 then
				newSpinner.BrickColor = BrickColor.new("Bright orange")
			elseif color.Value == 2 then
				newSpinner.BrickColor = BrickColor.new("Bright yellow")
			elseif color.Value == 3 then
				newSpinner.BrickColor = BrickColor.new("Bright green")
			elseif color.Value == 4 then
				newSpinner.BrickColor = BrickColor.new("Bright blue")
			elseif color.Value == 5 then
				newSpinner.BrickColor = BrickColor.new("Bright violet")
			elseif color.Value == 6 then
				newSpinner.BrickColor = BrickColor.new("White")
			elseif color.Value == 7 then
				newSpinner.BrickColor = BrickColor.new("Black")
			end

			if shape.Value == 0 then
				newSpinner.Shape = Enum.PartType.Cylinder
			elseif shape.Value == 1 then 
				newSpinner.Shape = Enum.PartType.Block
			end

			if material.Value == 0 then
				newSpinner.Material = Enum.Material.SmoothPlastic
			elseif material.Value == 1 then
				newSpinner.Material = Enum.Material.Wood
			elseif material.Value == 2 then
				newSpinner.Material = Enum.Material.Rock
			elseif material.Value == 3 then
				newSpinner.Material = Enum.Material.Ice
			elseif material.Value == 4 then
				newSpinner.Material = Enum.Material.Carpet
			elseif material.Value == 5 then
				newSpinner.Material = Enum.Material.Neon
			elseif material.Value == 6 then
				newSpinner.Material = Enum.Material.ForceField
			end

			local trailColorSequence = ColorSequence.new(Color3.new(1,1,1))
			if trail.Value == 0 then
				trailColorSequence = ColorSequence.new(Color3.new(1,1,1))
			elseif trail.Value == 1 then
				trailColorSequence = ColorSequence.new(Color3.new(1, 0.498314, 0))
			elseif trail.Value == 2 then
				newSpinner.Trail.Color = ColorSequence.new(Color3.new(1, 0.918486, 0))
			elseif trail.Value == 3 then
				newSpinner.Trail.Color = ColorSequence.new(Color3.new(0.18291, 1, 0))
			elseif trail.Value == 4 then
				newSpinner.Trail.Color = ColorSequence.new(Color3.new(0, 0.315496, 1))
			elseif trail.Value == 5 then
				newSpinner.Trail.Color = ColorSequence.new(Color3.new(0.613642, 0, 1))
			elseif trail.Value == 6 then
				newSpinner.Trail.Color = ColorSequence.new(Color3.new(1, 0, 0))
			elseif trail.Value == 7 then
				newSpinner.Trail.Color = ColorSequence.new(Color3.new(0, 0, 0))
			end

			newSpinner.Trail.Color = trailColorSequence

			newSpinner.Parent = game.Workspace
			spinners.Value -= 1
	newSpinner.Position = player.Character:WaitForChild("Right Arm").Position
	local direction = (tapPosition - newSpinner.Position).unit
	local initialVelocity = 100 * SSM.Value

	newSpinner.Anchored = false
			
			
			
	local bv = Instance.new("BodyVelocity")
	bv.Velocity = direction * initialVelocity
	bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	bv.P = 10000
	bv.Parent = newSpinner

	local bav = Instance.new("BodyAngularVelocity")
	bav.AngularVelocity = Vector3.new(0, 100, 0) -- Rotate only on the Y-axis (adjust the rotation speed as needed)
	bav.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
	bav.P = 10000
	bav.Parent = newSpinner

	newSpinner.Touched:Connect(function(otherPart)
		local character = otherPart.Parent
		if character:IsA("Model") and character:FindFirstChild("Humanoid") and character ~= player.Character then
			local humanoid = character:FindFirstChild("Humanoid")
			humanoid:TakeDamage(25*DMGM.Value)
			game.Workspace.Sounds.Impact:Play()
			newSpinner:Destroy()
					game.Workspace.Sounds.Stopping:Stop()
		end
	end)
		
		game.Workspace.Sounds.Stopping:Play()
		game.Workspace.Sounds.Throw:Play()

		local animt = hum:LoadAnimation(script.Throw)
		animt:Play()
		
	wait(0.5) -- Wait for 0.5 seconds
	game.Workspace.Sounds.Stopping:Play()

	-- Stop the spinner for 0.5 seconds
	bv.Velocity = Vector3.new(0, 0, 0)
	bav.AngularVelocity = Vector3.new(0, 0, 0) -- Stop the rotation
	wait(0.5) -- Wait for 0.5 seconds

	-- Set the destination to the player's right arm
	local rightArmPosition = player.Character:WaitForChild("Right Arm").Position
	local returnDirection = (rightArmPosition - newSpinner.Position).unit
	bv.Velocity = returnDirection * initialVelocity

	wait(0.5) -- Wait for 0.5 seconds
	game.Workspace.Sounds.Stopping:Stop()
			newSpinner:Destroy()
			wait(0.1)
			db = false
			wait(3*CoolReduction.Value)
			spinners.Value += 1

			
			
		elseif espinners.Value > 0 then 
			local newSpinner = spinnerTemplate:Clone()
			newSpinner.Parent = game.Workspace
			espinners.Value -= 1
			newSpinner.Position = player.Character:WaitForChild("Right Arm").Position
			local direction = (tapPosition - newSpinner.Position).unit
			local initialVelocity = 100 * SSM.Value

			newSpinner.Anchored = false

			local bv = Instance.new("BodyVelocity")
			bv.Velocity = direction * initialVelocity
			bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
			bv.P = 10000
			bv.Parent = newSpinner

			local bav = Instance.new("BodyAngularVelocity")
			bav.AngularVelocity = Vector3.new(0, 100, 0) -- Rotate only on the Y-axis (adjust the rotation speed as needed)
			bav.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
			bav.P = 10000
			bav.Parent = newSpinner

			newSpinner.Touched:Connect(function(otherPart)
				local character = otherPart.Parent
				if character:IsA("Model") and character:FindFirstChild("Humanoid") and character ~= player.Character then
					local humanoid = character:FindFirstChild("Humanoid")
					humanoid:TakeDamage(25*DMGM.Value)
					game.Workspace.Sounds.Impact:Play()
					newSpinner:Destroy()
					game.Workspace.Sounds.Stopping:Stop()
				end
			end)

			game.Workspace.Sounds.Stopping:Play()
			game.Workspace.Sounds.Throw:Play()

			local animt = hum:LoadAnimation(script.Throw)
			animt:Play()

			wait(0.5) -- Wait for 0.5 seconds
			game.Workspace.Sounds.Stopping:Play()

			-- Stop the spinner for 0.5 seconds
			bv.Velocity = Vector3.new(0, 0, 0)
			bav.AngularVelocity = Vector3.new(0, 0, 0) -- Stop the rotation
			wait(0.5) -- Wait for 0.5 seconds

			-- Set the destination to the player's right arm
			local rightArmPosition = player.Character:WaitForChild("Right Arm").Position
			local returnDirection = (rightArmPosition - newSpinner.Position).unit
			bv.Velocity = returnDirection * initialVelocity

			wait(0.5) -- Wait for 0.5 seconds
			game.Workspace.Sounds.Stopping:Stop()
			newSpinner:Destroy()
			wait(0.1)
			db = false
			wait(3*CoolReduction.Value)
		end
		end
end)

Is this what you’re looking for?

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