Gun that can shoot a camera and break it

I would really like to know if its possible to create a gun where when it shoots the security camera on the wall then it changes a bool value to true and then the camera unanchors and breaks off the wall.

This Will Be On A One Player Server (one player game)

Please, if you know then give an example (if possible) in the comments

2 Likes

It obviously is. You can either make an invisible hitbox part and add a check to the raycast for whether one of the hitboxes is hit and whether it is parented to a model parented to whatever your cameras are in.

2 Likes

How would I do that, I’ve never used raycast before and I’m a pretty bad scripter. could you give me an example please so I can mark it as the solution for this page?

Your weapon’s script has :Raycast() called somewhere. That method returns a raycast result which has an Instance property which is a part that got hit or nil if nothing was in the way.

Obviously your weapon’s script will look different, but the concept is the same.

local result  = workspace:Raycast(origin, direction, parameters)
local part = result.Instance

if part then
    local model = part.Parent
    if part.Name == "RayDetector" then
        part:Destroy()
        --handle the camera
    else
        local human = model:FindFirstChild("Humanoid")
        if human then
            -- handle character
        end
    end
end
4 Likes

thank you so much for helping : )