I need help with a script that is supposed to change touching to true while you are on a part and change it to false when you walk off, but it doesn't work, it sets it to true but not false. Can someone help?
local touching = false local canchange = false local changeable = true script.Parent.Touched:Connect(function(touched) touching = true canchange = false print(touching) end) script.Parent.TouchEnded:Connect(function(touched) if changeable == true then changeable = false canchange = true wait(1) if canchange == true then touching = false end changeable = true end print(touching) end)
You've made it too complicated. Use this to help you.
local touched = false script.Parent.Touched:Connect(function() if touched == false then print("true") touched = true end end) script.Parent.TouchEnded:Connect(function() if touched == true then print("False") touched = false end end)
This script works so if you want to use it then go ahead.