When i enter the Entertainment giver zone, it starts giving me Entertainment every 0.4s, but it won't end at mood.Entertainment.Value being 100, it still goes until infinite, and when i leave the Entertainment giver zone and go in again, it gives me 10x Entertainment faster. Also i want it to be like when you stop touching, the value stops increasing, when you touch it again the value increases again.
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if script.Parent.Parent.Status.Value == true then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local mood = game.ReplicatedStorage[player.Name.."'s Mood"]
if mood.Entertainment.Value < 100 and debounce == false then
debounce = true
while true do
wait(0.4)
mood.Entertainment.Value = mood.Entertainment.Value + math.random(1,2)
end
end
end
end
end)
script.Parent.TouchEnded:Connect(function()
debounce = false
wait(1)
debounce = true
end)

2 comments
Also when touch ends, and i touch the part again it goes faster and the value goes more than 100
I want it to be like when you stop touching, the value stops increasing, when you start touching it again, it starts increasing again.