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

How do I make lazers not kill you when it disappears?

Asked by 4 years ago

I have tried making something but it doesn't seem to be working, here is my script in the lazer:

function onTouch(part)
    if script.Parent.Transparency == 0 then
        local humanoid = part.Parent:FindFirstChild("Humanoid")
        if (humanoid ~= nil) then
            humanoid.Health = 0
        end
    end
end

while true do
    script.Parent.Transparency = script.Parent.Transparency + 0.5
    wait(0.5)
    script.Parent.Transparency = script.Parent.Transparency + 0.5
    wait(1)
    script.Parent.Transparency = 0
    wait(1.5)
end

script.Parent.Touched:Connect(onTouch)


0
Try printing. Soban06 410 — 4y
0
yeah I've tried and it printed everywhere but the script still doesn't work TheKakYTArmy 125 — 4y
0
move your "script.Parent.Touched:Connect(onTouch)" above your "while true do" 9mze 193 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

sorry this is a late reply but

function onTouch(hit)
    local h = hit.Parent:FindFirstChild("Humanoid")
    if h ~= nil then
    h.Health = 0
    end
    end

script.Parent.Touched:Connect(onTouch)




not sure how to do the when its invisible not kill but i would suggest to add and if then elseif to your script saying if its transparency == 0 then h.Health = 0 else if transparency == 1 then h.Health = 10 or something along those lines have a look at dev forum, google ect to find out how

0
that is exactly what I did TheKakYTArmy 125 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

would this work? function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then -- if a humanoid exists, then humanoid.Health = 0 -- damage the humanoid end end function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") script.Parent.Touched:connect(onTouch) if script.Parent.Transparency == 1 then if (humanoid ~= nil) then humanoid.Health = 0 end end end

0
I've tried this and it didn't work neither TheKakYTArmy 125 — 4y

Answer this question