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

How do i continuously check if a part is touching another?

Asked by 2 years ago

I am attempting to make a drowning system for my game, but whenever a player touches another part, it just stops activating, how do I keep checking if a part is touching another (like every 5 seconds)

2 answers

Log in to vote
0
Answered by 2 years ago

You could try this

local debounce = false

script.Parent.Touched:connect(function(hit)
    print("hit")
    local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
    if player then
        if debounce == true then return end
        debounce = true
        local check = player.Character:FindFirstChild("name here")
        if not check then
            --Enable the drowning here
            local newValue= Instance.new("BoolValue")
            newValue.Name = "name here"
            newValue.Parent = player.Character
            script.Parent.TouchEnded:wait()
            --Disable it here   
            newValue()
        end
        debounce = false
    end
end)
0
"local check = player.Character:FindFirstChild("name here")" tymon4don 6 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

managed to do it with positions

Answer this question