My Part isn't appearing in front of the player when Key is pressed

I’m trying to have my part appear in front of the character as soon they press F but its not working. I tried to do Vector3 but I was told CFrame was a better way to do it.

[Local Script]

local UIS = game:GetService("UserInputService")
local RS = game:GetService("ReplicatedStorage")
local Remote = RS.Remotes:WaitForChild("FireSummonEvent")
local debounce = false
local FiresummonPart = RS.Misc:WaitForChild("FS")


UIS.InputBegan:Connect(function(Input, GP)
   if GP then return end
   if Input.KeyCode == Enum.KeyCode.F and not debounce then
   	debounce = true
   	debounce = false

[Server Script]

local RS = game:GetService("ReplicatedStorage")
local Remote = RS.Remotes:WaitForChild("FireSummonEvent")
local FiresummonPart = RS.Misc:WaitForChild("FS")

	local Character = Player.Character or Player.CharacterAdded:Wait()
	local HRP = Character:WaitForChild("HumanoidRootPart")
	local FireBall = FiresummonPart:Clone()
FireBall.CFrame = HRP.CFrame *,0,10)

What worked for me was CFrame.lookAt(). So my code was:
humanoidrootpart2.CFrame = CFrame.lookAt(humanoidrootpart1.Position +, 0, 3), humanoidrootpart1.Position)

So in this case, yours would be:

Fireball.CFrame = CFrame.lookAt(HRP.Position +,0,3), HRP.Position)

I hope this helps!


If that doesn’t work, try:

FireBall.Position = HRP.Position + (HRP.CFrame.LookVector * 10)

and if you need it to look towards the player, then

FireBall.Position = CFrame.lookAt(HRP.Position + (HRP.CFrame.LookVector * 10), HRP.Position)

You need to set the Parent property of the cloned FiresummonPart. You could set this to the workspace or also most any descendant of the workspace

1 Like

You might also want to implement a server sided debounce to prevent exploiters from lagging out your game with parts.

1 Like

This was a huge help! Worked like a charm. All though WartioSvug did solve the appearance problem, your answer is what I was looking for. Lookvector was a better option then CFrame.LookAt




Thank you for the suggestion, I will do this ASAP