Hey scriptinghelpers, so I don't actually know how to do this. I can't seem to find much about it either. I was wondering how do I check for a player (in my case probably multiple players but I want it all to be separate since it's awarding points) while they're touching a part instead of onTouch. The onTouch is a one time deal, I'm looking to wait 1 second then continue to award 1 point every second while they player is touching the part. Below you find my onTouch code that I'm looking to turn into a while touching. I'm not sure how to do this.
This is a Script inside of a Part (inside of Workspace)
local part = script.Parent
local function onTouch(tixPart)
local humanoid = tixPart.Parent:FindFirstChild("Humanoid")
if humanoid then
local player = game.Players:FindFirstChild(tixPart.Parent.Name)
if player then
player.leaderstats.Tix.Value = player.leaderstats.Tix.Value + 1
wait(1)
end
end
end
part.Touched:Connect(onTouch)
I do know about TouchEnded but, I don't really know like the way I would go about checking for "while touching". Like I said there will be multiple players inside the part at one time so, I do want to make sure that all the players are awarded the points while they're touching the part. Not just one player. I did try it with this, but it's a one time deal unless you retouch it again. I actually removed the debounce because I thought it might help but, now it just awards multiple for every player part (head, arms, torso, etc.) that touches it. Once again, this is only a one time deal. Thank you for the help in advance! I appreciate it.

2 comments
Oh sweet, thank you scripterhelper5354. I did some testing and there is an error on line 25 but I just removed it and it works perfectly fine. I'll get back to you after I finish testing some more. Thanks again! I really appreciate it.
That's pretty awesome. I never even knew about this! Thanks again again, I learned something new today.