You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
Inside of my firearm, there is a server script that fires a raycast to the players Mouse Position.
When the player shoots towards the sky, the raycast visualizer part goes over a trillion studs into the sky since that’s basically where the mouse’s position is. So basically, I want to add a limit to how far a player can shoot, but I do not have the knowledge on how to.
- What is the issue? Include screenshots / videos if possible!
In this video, you will see that the raycast part is not visible to the human eye nor a computer because of how far away it is and the Roblox graphics settings being below max.
Sorry for a decently loud audio. As of writing this, the audio has been fixed to a lower hearing level inside of the place created with Roblox Studio.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried a lot of solutions but none have worked I have even asked too but the solution didn’t work.
Now, I will show you my code that I have written using Roblox studios editor.
This code I will present to you is the code that is in the server script, that creates the raycast.
local Cast = workspace:Raycast(ShootPos,(MousePos-ShootPos).Unit*2000)
In that code example, you can see that I tried to use Unit*200 as it was supposed solution, but my bullet was still too far in the sky for the human eye to see.
The next code I will present to you is the main part of it all, the raycast visualizer.
if Config.VisibleRaycastBullet.Value == true then
if Cast then
result = Cast.Position
end
local distance = (ShootPos - result).Magnitude
local p = Instance.new("Part")
p.Anchored = true
p.CanCollide = false
p.Size = Vector3.new(0.05, 0.05, distance)
p.BrickColor = BrickColor.new("New Yeller")
p.Parent = workspace
p.Transparency = .5
p.Material = Enum.Material.Neon
p.CanQuery = false
p.CanTouch = false
p.CastShadow = false
local directionCF = CFrame.new(ShootPos, result)
p.CFrame = directionCF
p.Position += directionCF.LookVector * math.abs((ShootPos - result).Magnitude)/2
local t = game.TweenService:Create(p,TweenInfo.new(Config.VisibleRaycastBullet.Time.Value),{Transparency = 1})
game.Debris:AddItem(p,Config.VisibleRaycastBullet.Time.Value)
end
That is my problem. I am looking for some kind of solution, any help is heavily appreciated.