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

What could possibly be wrong with my Volume-detection script?

Asked by 6 years ago

In a nutshell: I'm (attempting) to make a script that detects when a player is inside of a part, and then acts accordingly. Simple, right? Yet here I am, unable to find an answer after literally hours of searching. I need a bool value to be changed whenever you are inside a part, and then continually (at ~1 second intervals) be tested for to see if you are still inside that part.

local char = script.Parent
isTouching= false
hum = script.Parent.Humanoid
mainBodyPart = char.LowerTorso

local function touchedWarmer(hitPart)
    if hitPart.Name == "Heat_Volume_Inactive" then
    isWarming = true
    print "Warming"
    end
end

local function stoppedWarming(hitPart)
    if hitPart.Name == "Heat_Volume_Inactive" then
        isWarming = false
        print "Freezing"
    end
end

--here is where the code dealing with the actual changes being made, i.e. what to do if it is/isn't being touched

mainBodyPart.Touched:connect(touchedWarmer)
mainBodyPart.TouchEnded:connect(stoppedWarming)

The script is in StarterCharacterScripts. Any help would be much appreciated, even if the answer is staring me in the face.

0
make a bool outside of the functions called, InPart and list it as true in touched and false in touchended AttentionHog 70 — 6y

Answer this question