Help scripting a PVP move

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!

simply put, i want to make a move where the player throws their weapon in an arc, landing 50 studs infront of where it was launched.
(i cant seem to throw the weapon without it breaking, but i do not need that fixed rn.)
2. What is the issue? Include screenshots / videos if possible!

i looked at a tutorial for beizer projectiles, and i followed that, but i tried to edit it so that instead of the projectile landing at mouseposition, it will land 50 studs in front of the player. however, when i tried to change it, i guess it partially worked, but it landed 50 studs away from 0,0,0 instead of HumanoidRootPart.CFrame.LookVector * 50. i have not been able to fix this.
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i could not find a solution on DevForum.
i am an novice scripter, please tell me how to fix this and provide an example code so i can learn.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
--^^services
local CRATERPIECES = 16

local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()

local function Lerp(a, b, t)
	return a + (b-1) * t
end

local function Curve(t,P0,P1,P2)
	local a = P0:Lerp(P1,t)
	local b = P1:Lerp(P2,t)
	return a:Lerp(b,t)
end
	
--this next function is optional.
local function MakePart(position,cframe,transparency,shape,color,material,size,anchored,collide)
	local part = Instance.new("Part")
	part.Anchored = anchored
	part.CanCollide = collide
	if cframe then
		part.CFrame = cframe
	end
	part.Transparency = transparency
	part.Size = size or Vector3.new(1,1,1)
	part.Shape = shape or "Block"
	part.Material = Enum.Material[material] or Enum.Material.Plastic
	part.Color = color or Color3.fromRGB(255,255,255)
	part.Parent = workspace
	
	return part
end

local function Tween(part,goals,t,style,direction)
	local info = TweenInfo.new(t,Enum.EasingStyle[style],Enum.EasingDirection[direction],0,false,0)
	return TS:Create(part,info,goals)
end

--the style of explosion; change this later to fit your attack.



local RADIUS = 7
local function Projectile(mousePosition,amount,speed)
	local endPoint = mousePosition
	local HRP = character:FindFirstChild("HumanoidRootPart")
	local mid = (HRP.Position - endPoint).Magnitude
	if mid <= 50 then
		mid = 50
	end

	local side = {
		[1] = -1,
		[2] = 1,
	}
	for v = 1, amount do
		task.spawn(function()
			local side = side[math.random(1,#side)]
			local orb = MakePart(HRP.Parent,nil,0,"Block",Color3.fromRGB(170,85,255),"Neon", Vector3.new(1,1,1),true,false)
			
			
			for i = 0, speed do
				local curve = Curve(i/speed,HRP.Position,(HRP.CFrame * CFrame.new((mid/4)*side,mid/4,-mid/4)).p,endPoint)
				orb.Position = curve
				task.wait(0.01)	
				
				
			end 
			
			 local function Explosion(radius,Position,rockSize)
				local radius = 15
				local Position = Vector3.new(orb.Position.X,orb.Position.Y,orb.Position.Z)
				local rockSize = 2
				local module = require(game.ReplicatedStorage.CraterModule)
				module.Create(radius,Position,rockSize)

			end	
			Explosion(Color3.fromRGB(170,85,255), orb.Position,20)
			Explosion(35, RADIUS, 4)
			Explosion(-35, RADIUS * .9, 4)
			game.Debris:AddItem(orb,1)
	end)		end
		task.wait(.3)
	end


UIS.InputBegan:Connect(function(input, gp)
	if gp then return end
		local HRP = character:WaitForChild("HumanoidRootPart")
		local mid = (HRP.Position - mouse.Hit.p).Magnitude
		if input.KeyCode == Enum.KeyCode.R then
			Projectile(mouse.Hit.p, 1, 40)
						
					
				
			
		
	end
end)
2 Likes

in case you couldent tell,(you probably could) this is a localscript, and there is a module script elsewhere, for a crater upon landing.

1 Like

If it’s landing 50 studs from 0, 0, 0, you need to add that position to the CFrame of the humanoid root part.

1 Like

i know, the script i gave you was changed back to the original. i tried to change local endpoint from mouseposition to HRP.CFrame.LookVector * 50.

1 Like

It’s not the lookvector, you have to literally add the two positions / cframes together.

character:GetPivot() * CFrame.new(bezierCurvePosition)
1 Like

what would i put in the beizercurveposition?

1 Like

You would put the position of the bezier you calculated. Use that exact expression, I don’t know how your code works.

1 Like

i don’t quite understand and i can’t get on studio rn, but once i can, i will try this and get back to you on if this works or not, or if i need additional help💀 thanks!

2 Likes

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