The (owner == plr) on line 10 is not being met. The local owner Value is an ObjectValue and I need it to stay that way. I am not sure what is wrong I have been trying to figure it out for hours any help would be great.
button = script.Parent
regen = button.Parent.Regen
local owner = script.Parent.Parent.Parent.Owner1.Value --This is an ObjectValue I need it to stay that way.
local debounce = false
function onTouch(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
local plr = hit.Parent.Name
if h ~= nil and debounce == false and owner == plr then --The (owner == plr) is not being met.
print("pass")
debounce = true
button.BrickColor = BrickColor.Red()
regen.Value = 1
wait(1)
regen.Value = 0
wait(5)
button.BrickColor = BrickColor.Blue()
debounce = false
else
print("fail")
end
end
button.Touched:connect(onTouch)

5 comments
plr is a string. Try getting the player from their character.
Can you please explain how to do that?
"plr" is referring to the player's name not the player themselves, that means you're comparing an object to a name, i think it will work if the "plr" variable refers to the player, and not their name with the use of this line : local plr = game.Players:FindFirstChild(hit.Parent.Name)
https://developer.roblox.com/api-reference/function/Players/GetPlayerFromCharacter
O Now i see whats going on. Thanks Phlegethon5778 and strongrussianboy123!