So I am trying to make a part point towards a position.
When i have run into this error
Why is this happeing?
local function fireBullet(player, tool, po)
local rs = game:GetService('RunService')
local poPart = Instance.new('Part')
poPart.Position = po
local bullet = game:GetService('ReplicatedStorage'):FindFirstChild('Bullet'):Clone()
bullet.Position = tool:FindFirstChild('Handle').Position
bullet.Parent = workspace
print(po)
bullet.CFrame = CFrame.lookAt(poPart.Position)
rs.Heartbeat:Connect(function()
bullet.CFrame = bullet.CFrame * CFrame.new(1,0,0)
end)
end
1 Like
bigfart_mp4
(bigfart_mp4)
November 20, 2022, 11:21pm
#2
change this line and see if it’s fixed.
bullet.CFrame = CFrame.lookAt(CFrame.new(poPart.Position))
Same things still happening.
It needs a Vecter3 not a cframe
bigfart_mp4
(bigfart_mp4)
November 20, 2022, 11:24pm
#4
then try vector3.new
character limit
Still not working.
Anymore ideas?
bigfart_mp4
(bigfart_mp4)
November 20, 2022, 11:26pm
#6
bullet.CFrame = CFrame.lookAt(Vector3.new(poPart.Position), Vector3.new(bullet.CFrame))
SOTR654
(SOTR654)
November 20, 2022, 11:28pm
#7
If po
is where it should be facing, use it as the second parameter and the first should be the bullet position.
bullet.CFrame = CFrame.lookAt(bullet.Position, po)
1 Like
Well this works for the most part.
Except that it is making it point 90 degrees off.
How do I make it turn by 90 degrees?
SOTR654
(SOTR654)
November 20, 2022, 11:34pm
#9
Add CFrame.Angle(math.rad(90), 0, 0)
, if the direction is still not correct, change math.rad
to the other axis until it rotates correctly, also try with -90
.
bullet.CFrame = CFrame.lookAt(bullet.Position, po) * CFrame.Angle(math.rad(90), 0, 0)
FroDev1002
(FroDev)
November 20, 2022, 11:40pm
#10
This is not having any effect on it.
SOTR654
(SOTR654)
November 20, 2022, 11:43pm
#11
Did you try other math.rad
positions?
FroDev1002
(FroDev)
November 20, 2022, 11:45pm
#12
yes I did
Still not working
I have no idea how to fix this
Try this, it should work.
local function fireBullet(player, tool, po)
local rs = game:GetService('RunService')
local bullet = game:GetService('ReplicatedStorage'):FindFirstChild('Bullet'):Clone()
bullet.Position = tool:FindFirstChild('Handle').Position
bullet.Parent = workspace
bullet.CFrame = CFrame.lookAt(bullet.Position,po) * CFrame.Angles(math.rad(90),0,0)
rs.Heartbeat:Connect(function()
bullet.CFrame = bullet.CFrame * CFrame.new(1,0,0)
if not bullet then
break -- dont keep too many heartbeats
end
end)
end
It may be a bit late, but I hope it helps.
I figured it out!
I just had to change which direction it moves in!
system
(system)
Closed
March 9, 2023, 1:03am
#15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.