So im making attachements for my game and im working on the laser, its fine except the laser is offset to the crosshair. I fixed this with code to follow your crosshair
I made a piece of code to follow your crosshair and it works except in third person it still follows your mouse and for other clients it will look weird since i made it 1 local script handling all lasers in workspace. Please help me make the laser go to crosshair while not following it in third person and still looking fine for other clients (With this i mean since its a client script someone elses laser will follow the other clients mouse and so on so on)
local RaycastParameters = RaycastParams.new()
RaycastParameters.IgnoreWater = true
RaycastParameters.RespectCanCollide = true
RaycastParameters.FilterType = Enum.RaycastFilterType.Exclude
RaycastParameters.FilterDescendantsInstances = {}
local Mouse = game.Players.LocalPlayer:GetMouse()
game:GetService("RunService").RenderStepped:Connect(function()
for i,Value in next, game:GetService("Workspace"):GetDescendants() do
if Value:IsA("Part") and Value.Name == "GunLaser" and Value.Parent:FindFirstChild("SightPoint") then
local Raycast = workspace:Raycast(Value.From.WorldPosition, Mouse.Hit.LookVector * 300, RaycastParameters)
if Raycast and Raycast.Instance then
Value.To.WorldPosition = Raycast.Position
else
Value.To.CFrame = CFrame.new(0,0,-500) * CFrame.Angles(0,0,0)
end
end
end
end)
Its a localscript in starterplayerscripts. I am not gonna do server since it wont be smooth and i dont like it. Here are the properties of the laser
Im gonna be sleeping so dont expect a reply for like the next 12 hours. Goodnight