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

How to remove a bullet from the world when it touches something with filtering enabled on?

Asked by 5 years ago

Here is my damage script. It is put inside the bullet when it is fired. I have tried removing the bullet in many different spots but they destroy the script. Please help.

script.Parent.Touched:Connect(function(hit)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, h, mouse)
        if hit.Name == "Handle" then return end
        local h = hit.Parent:FindFirstChild("Humanoid")     
        if h  then
            if hit.Parent.Name ~= plr.Name then     
                h:TakeDamage(10)
            end
        end
end)
end)
0
Do not pass the mouse on a server script User#19524 175 — 5y
0
You can destroy the bullet since there's no bullet. User#22219 20 — 5y
0
can't * User#22219 20 — 5y
0
Destroy() destroys a part AND all of its children, so if the script is inside the bullet, it also is destroyed Tymberlejk 143 — 5y
View all comments (2 more)
0
Plus you don't need to put a script inside. User#22219 20 — 5y
0
When you raycast, it return hit, position (and two other CFrame stuff). Hit is where it hits, and position is where it is. User#22219 20 — 5y

Answer this question