Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)


3 comments

0

Try printing.

0

yeah I've tried and it printed everywhere but the script still doesn't work

0

move your "script.Parent.Touched:Connect(onTouch)" above your "while true do"

2 answers

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

1 comment

0

that is exactly what I did

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

1 comment

0

I've tried this and it didn't work neither

This discussion is preserved as it was. New answers, comments, and votes are closed.