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:

01function onTouch(part)
02    if script.Parent.Transparency == 0 then
03        local humanoid = part.Parent:FindFirstChild("Humanoid")
04        if (humanoid ~= nil) then
05            humanoid.Health = 0
06        end
07    end
08end
09 
10while true do
11    script.Parent.Transparency = script.Parent.Transparency + 0.5
12    wait(0.5)
13    script.Parent.Transparency = script.Parent.Transparency + 0.5
14    wait(1)
15    script.Parent.Transparency = 0
16    wait(1.5)
17end
18 
19script.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

1function onTouch(hit)
2    local h = hit.Parent:FindFirstChild("Humanoid")
3    if h ~= nil then
4    h.Health = 0
5    end
6    end
7 
8script.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