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

How to disable script when a part is not touched? [closed]

Asked by 3 years ago

My script:

local Player = game:GetService("Players")
local debounce = false

function Touched(hit)
    if debounce == false then
        local player = Player:GetPlayerFromCharacter(hit.Parent)
        player:FindFirstChild("StarterGui").Animations.AnimationList.Animationcontroller.Disabled = false
        debounce = true
    end
end

function TouchEnded(hit)
    if debounce == true then
        local player = Player:GetPlayerFromCharacter(hit.Parent)
        player:FindFirstChild("StarterGui").Animations.AnimationList.Animationcontroller.Disabled = true
        debounce = false
    end
end

script.Parent.Touched:Connect(Touched)
script.Parent.TouchEnded:Connect(TouchEnded)

It doesn't work for me any suggestions?

Closed as Non-Descriptive by JesseSong

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?