What do you want to achieve?
Because the giant walls meant to stop raycasts from leaving don’t work when they aren’t rendered, I’d like to “fake” a Beam to the end of a raycast.
What is the issue?
When an unrendered area is shot, raycastResult turns out nil no matter what is actually there
local function FireCast()
local direction = (mouse.Hit.Position - rayOrigin.Position)
local raycastResult = workspace:Raycast(rayOrigin.Position, direction * range,raycastParams)
return raycastResult
end
local function sendHitInfoPrecise(hitPosition)
remoteEvent:FireServer(hitPosition)
end
local function onClickhhh()
local mouse = plr:GetMouse()
local raycastResult = FireCast()
sendHitInfoPrecise(raycastResult.Position) --line 44
end
What solutions have you tried so far?
I can’t get my solutions to work, and the devforum is not much of help so far.
That would have a delay between clicking and raycast being fired.
I am looking for a solution that instead sends the beam from the precise hit position out to the end of the raycast (~2000 studs out).
It is checked by server after being cast, but I want it to not produce an error when shot at unrendered areas.
I’ll implement a raycastResult check before firing the beam, but that would cause the issue of nothing happening when hitting an unrendered area or no area at all.
The raycast stops after 2000 studs, and we have the direction that the beam was fired. How would we make a Beam particle link to where it lands?
You should handle nil results separately and place the beam’s end far away in the direction of the raycast, something like:
if raycastResult == nil then
Attachment0.Position = rayOrigin.Position
Attachment1.Position = rayOrigin.Position + direction * 5000
else
--your current code
end
--using the two attachments connecting the beam
This will place Attachment1 Far away in the direction of the beam, making it appear as so the beam has still shot and hit somewhere