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")
---script///
UIS.InputBegan:Connect(function(Input, GP)
if GP then return end
if Input.KeyCode == Enum.KeyCode.F and not debounce then
print("BOOM")
debounce = true
Remote:FireServer()
wait(5)
debounce = false
end
end)
[Server Script]
local RS = game:GetService("ReplicatedStorage")
local Remote = RS.Remotes:WaitForChild("FireSummonEvent")
local FiresummonPart = RS.Misc:WaitForChild("FS")
Remote.OnServerEvent:Connect(function(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
local HRP = Character:WaitForChild("HumanoidRootPart")
local FireBall = FiresummonPart:Clone()
FireBall.CFrame = HRP.CFrame *CFrame.new(0,0,10)
end)
What worked for me was CFrame.lookAt(). So my code was:
humanoidrootpart2.CFrame = CFrame.lookAt(humanoidrootpart1.Position + Vector3.new(0, 0, 3), humanoidrootpart1.Position)
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