Simply put, I cant seem to access the Position of a Raycast Im making
Whenever I try to do arithmetic with it, it constantly states it as ‘nil’
I tried printing it out and apparently theres two values?
I’ll be up late so I should be able to answer any questions for tonight, sorry if this wasnt clear enough, just ask and I’ll try my best to explain better.
I have a message thats pending for an absurd amount of time for moderation for some reason
But it just said that
The code is simply just me making a raycast, passing the position into a function, and then printing it
I was aiming at a wall when doing this, and it did seem to print the actual position of the raycast, but it also prints nil at the same time?
Which in turn just marks it as nil instead
Oh wait, theres also this, It should just handle if the raycast if pointed at the sky, could this be the problem?
(sorry for forgetting about this in the first place)
if not Bullet then
EndPos = BStart + Camera.CFrame.LookVector * RANGE
else
EndPos = Bullet.Position
end
The entirety of the code that should be relevant now
function RenderClientBullet(Origin, RaycastResultPosition)
print(RaycastResultPosition)
end
function FireClientBullet()
local EndPos
local BStart = FlashParticle.Parent.WorldPosition
local Direction = (Mouse.Hit.Position - BStart).Unit
local Bullet = workspace:Raycast(BStart, Direction * RANGE, Parameters)
if not Bullet then
EndPos = BStart + Camera.CFrame.LookVector * RANGE
else
EndPos = Bullet.Position
end
if Bullet then
RenderClientBullet(BStart, Bullet.Position)
end
end
I found a work-around at least,
Instead of passing the position of the raycast into the function, ill just do what I want with the position in the same block of code instead
Yet for some reason the position is fine until I pass it into a function, which then it becomes two values (the Vector3 and nil)