I want to make a system where if a player touches a specific part, then a value in it would change to true if not already, i have this script in the part :
local part = script.Parent
part.Touched:Connect(function(hit)
print("Touched")
if hit then
if hit.Parent:FindFirstChild("Humanoid") then
print("An humanoid Touched")
local p = game.Players[hit.Parent.Name]
print(hit.Parent.Name)
local s = p:FindFirstChild("IsTouched")
if s then
print("Value found")
print("Changing....")
s.Value = true
print("Changed!")
end
end
end
end)
It work only one time and when i try a second time it doesn't
When i change the value manualy it works
it prints out everything on every tries i've made, even if the value does not change
Thanks for futur answers!

2 comments
Lets assume that the deafult value of your ("IsTouched" Bool) is false so instead of doing if s then you could do if s.Value == false then s.Value = true else s.Value = false i think this is what u wanted it do it?
And also you should probably add a debounce so that it doesn't fire multiple times if multiple body parts touch it