Want to make explosion appear in front pf player via offset

I recently made an explode menu, And i want to make it so that the X offset make the explosion appear in front of the player of where the character is looking, But explosion position needs a vector3, And vector3 has a foxed position, So i want to be able to make the explosion appear in front of the player with the given X value (in studs)
Current code:

RE18.OnServerEvent:Connect(function(plr, user, X, Y, Z, Pressure, Radius)
	if table.find(Allowed, plr.UserId) or admins:GetAsync(plr.UserId) then
		local player = checkplr(user)
		local char = game.Players:FindFirstChild(player).Character.HumanoidRootPart
		local boom = Instance.new("Explosion")
		boom.Parent=char
		boom.BlastPressure=Pressure
		boom.BlastRadius=Radius
		boom.Position=Vector3.new(char.CFrame.Position.X+X,char.CFrame.Position.Y+Y,char.CFrame.Position.Z+Z)
	end
end)

Use a CFrame.Position.
Get the CFrame of your character, add 10 studs in Z, and set the Explosion vector3 to CFrame.Position

local PosForExplosion = HRP.CFrame * CFrame.new(0,0,-10)
Explosion.Position = PosForExplosion.Position
1 Like
local offset = 5
explosion.Position = (rootPart.CFrame.lookVector) * offset

-- if it appears behind, change to

explosion.Position = -(rootPart.CFrame.lookVector) * offset

Vector3 expected, Got CFrame is what i am getting. So this does not work.

Then you are not doing it as the example I was showing, I tested it, and its very basic

whats the problem to use look vector aka CFrame = CFrame.LookVector*5

1 Like

I just fixed it. Still need to fix a few issues with positioning, But it works now.

Ofc theres no problem with using it, I was just giving an example that CFrame contains a Vector3 position, ofc is easier to just use LookVector :yum:

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