Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is FindPartOnRay not finding MeshParts?

Asked by 6 years ago
Edited 6 years ago

I know collisions are kind of broken right now for mesh parts.. saw some posts about it in the dev forum. I've been making some guns using raycasting, and i rectenly switched the system from tools to GUIs due to unequipping and welding issues, and for whatever reason now they won't detect anything but the HumanoidRootPart upon being fired at point blank range. At any other range, nothing will happen.

I really do believe it has something to do with meshpart's collisions or findpartonray's buggy lack of support for it?

code snippet in the GUI:

local bulletRay = Ray.new(tool.Handle.CFrame.p, (player:GetMouse().Hit.p - tool.Handle.CFrame.p).unit*tool.WeaponDetails.MaxBulletRange.Value)
            local part,position = workspace:FindPartOnRay(bulletRay,player.Character,false,true)
            tool.FireSound:Play()
            shootEvent:FireServer(tool,position,part,tool.fireAnimation)

code snippet in the server script:

local fireAnim = workspace[player.Name].Humanoid:LoadAnimation(animation)
        fireAnim:Play()

        if tool.FireSound.Playing == false then
            tool.FireSound:Play()
        end
        if part then
            local humanoid = part.Parent:FindFirstChild("Humanoid")
            if not humanoid then
                humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
            else
                if humanoid.Health > 0 then
                    humanoid:TakeDamage(damage.Value)
                    if humanoid.Health > 0 then
                        replicatedStorage.Weapons.WeaponHit:FireClient(player, false)
                    else
                        replicatedStorage.Weapons.WeaponHit:FireClient(player, true)
                    end
                end
            end

these are just partial, so it doesn't really have anything to do with syntax.

1 answer

Log in to vote
0
Answered by 6 years ago

Nevermind, found a solution!

Ad

Answer this question