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

Help with :Destroy()? [UNSOLVED]

Asked by 10 years ago
local function OnTouched(shot, otherPart)
    local character, humanoid = FindCharacterAncestor(otherPart)
    if character and humanoid and character ~= Character then
        ApplyTags(humanoid)
        if shot then
            local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
            if hitFadeSound then
                hitFadeSound.Parent = humanoid.Torso
                hitFadeSound:Play()
            end
            shot:Destroy()
        end
        Dematerialize(character, humanoid, otherPart)
    elseif otherPart.ClassName == "Part" then
        shot:Destroy()
    end
end

I have a laser and I want it to destory() the bullet if it touches a part, cause right now it goes through the part. Any help with this? It isn't showing any output, so don't know what the error is. Inside a LocalScript.

1 answer

Log in to vote
-2
Answered by 10 years ago

You simply forgot the Event part of the function. Just put this in.

script.Parent.Touched:connect(onTouched) -- assuming the script is in the part that you want to be touched 
0
that still dosent work :/ I just have a LocalScript inside a Tool. NinjoOnline 1146 — 10y
0
OH, that's the problem. The function fires when the tool is touched. Just change the "script.Parent" part to the object you want to be touched (i.e. game.Workspace.laser) whyOmustOitObeOme 7 — 10y
0
-Edit- I change it to the whole script, I am just using ROBLOX's HyperLaser, I think it should be around the bottom where it should be to destory if it doesnt hit a player but a part. Can you just have a quick look? NinjoOnline 1146 — 10y
0
Oh jeez, that's a lot of code. I most likely won't be able to detect a problem here. whyOmustOitObeOme 7 — 10y
View all comments (3 more)
0
maybe around 149 163 abouts NinjoOnline 1146 — 10y
0
I am pretty sure it has to be placed 143 -163 cause thats where it kills the player. I just dont know how to detect if the bullet hit a part instead of a player. Please just ook at that 20 lines of code NinjoOnline 1146 — 10y
0
I editte dagain with just the piece of code I need. I added an attemp on lines 14-15 but that just destroys the bullet the second is eaves the barrel NinjoOnline 1146 — 10y
Ad

Answer this question