Is it possible to use an if statement on a function, e.g:
local touched = false
script.Parent.Touched:Connect(function(hit)
warn("1")
if touched == false then
warn("2")
touched = true
while hit.Parent.Humanoid.Health >0 and touched == true do
warn("3")
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 1
wait()
if script.Parent.TouchEnded then -- is this possible?
warn("4")
touched = false
break
end
end
end
end)
Thanks!

5 comments
I'm not sure but I think it's not possible because it's an event. It's suppose to be script.Parent.TouchEnded:Connect(function() end).
No you can't do that, you can do TouchEnded:Wait() and it will yeild the script until the event occures
Your question and you script doesn't really match, you can use a function in an if statement. But you can't use an Event, which is what you're doing in your script
ok thx
i think you can use anything on if statements im pretty sure as along they dont refer to nil or false. Even you don't need to call the function you can still compare it since it's not nil or false