What is the issue? Include screenshots / videos if possible!
– My Script doesn’t raycast properly. When I place a part at the hit point, it places the part at some random position.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
– I’ve tried ignoring the viewmodel.
-- raycast and shoot ( main )
if currentservermodel then
local shootpoint = righteff.CFrame * CFrame.new(0,0,-0.5)
local rayshoot = Ray.new( shootpoint.p , cam.CFrame.LookVector * 5000 )
local ignorelist = { char , lasttool.ViewModel }
for i , v in pairs( workspace:GetChildren() ) do
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") then
if v.CanCollide == false then
table.insert( ignorelist , v )
end
end
end
local hitobj , hitpos , normal = workspace:FindPartOnRayWithIgnoreList( rayshoot , ignorelist )
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Position = hitpos
part.Size = Vector3.new(0.2,0.2,0.2)
part.Parent = workspace
part.Material = Enum.Material.Neon
cam.CameraType = Enum.CameraType.Scriptable
cam:Interpolate( CFrame.new( hitpos.X , hitpos.Y , hitpos.Z ) * CFrame.new(5,5,5) , CFrame.new( hitpos.X , hitpos.Y , hitpos.Z ) , 1 )
wait(1)
cam.CameraType = Enum.CameraType.Custom
end
The Camera Should move to the hit spot but it doesn’t.
It works fine at the start but doesn’t work at all after a few tries.
Not saying this will help your case, but just a possibility, because this occured to me before and it was just because position takes collisions into consideration. Worth a try
What exactly the problem is. You said the camera doesn’t move at all, but then you also said it works fine at the start.
More descriptive as to what exactly you want the script to do. I tested it out in studio and I’m guessing you want the camera to zoom in on the bullet but I’m not sure.
Yes.
I don’t know what the problem is. There’s a part rigged to the ViewModel from which the script raycasts towards the camera’s lookvector , and then creates a part where the ray was hit. Not sure why it doesn’t work.
I can make the game open for you to check it.
Look vector points in the negative Z direction, so it might be the reason behind your issues. Just negate the 5000 part. Also, rays can’t go beyond 1000.
I can’t access Roblox right now, so I can’t check for myself.
Does anything happen to the camera once it returns though? Try replacing the cam.CFrame.LookVector to the look vector of whatever the tool’s barrel is. If that stops breaking, then it’s an issue with the camera.