How can I get a tool to spawn an object where the player is facing?

Hey, I’m trying to make a tool to spawn an object where the player is facing but I cannot get it to work. I’ve tried using LookVector which I cannot get to work…

-- --/Services + Main Vars\--
local REPS = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local weaponSkill_Objects = REPS:WaitForChild("Weapon_Skill_Objects")
--/Object\--
local slashEffect = weaponSkill_Objects:WaitForChild("SlashEffect")
--/Events + Tool\--
local tool = script.Parent
local startAirSlash = tool:WaitForChild("StartAirSlash")

startAirSlash.OnServerEvent:Connect(function(plr, char)
	local cloneSlashEffect = slashEffect:Clone()
	cloneSlashEffect.Parent = workspace
	
	local humRP = char:FindFirstChild("HumanoidRootPart")
	print(humRP)
	
	local lookVector = char.Head.CFrame.LookVector
	print(lookVector)
	cloneSlashEffect.Position = char.Head.Position + lookVector * 5
	cloneSlashEffect.Orientation = Vector3.new(-30, -90, 0)
end)

Thanks!
robloxapp-20220618-1619583.wmv (1.8 MB) – Video

Why do you have the cloneSlashEffect Position 2 times?

cloneSlashEffect.Position = char.Head.Position + lookVector * 5
cloneSlashEffect.Position = humRP.Position + Vector3.new(0,3,0)

yeah, that was my bad, quickly got rid of it but still the same issue

It’s likely because you give it a predefined Orientation, if you want to spawn something infront of the player 5 studs forward and 3 up,

cloneSlashEffect.CFrame = char.Head.CFrame * CFrame.new(0,3,-5)

Should work from me testing by creating a Part, if it doesn’t but is close, you may need to tamper a bit with the CFrame.new part

thanks!! This was just what I needed! :+1:

1 Like