So I'm testing a different way to make some of my scripts more efficient by using the :wait() method instead of the .Touched() event, because the .Touched() event can fire multiple times before a debounce can even trigger. My only issue is getting the player after the part is touched. Here is what I have so far:
repeat until game:GetService("Players"):GetPlayerFromCharacter(Part.Touched:wait().Parent) --How do we know which Player touched it??
Is there any possible way to find out which Character would've touched the part to trigger the event? All help is appreciated.
-- My idea for getting players from touched parts is: local p=game.GetService'Players' script.Parent.Touched:connect(function(hit) p:GetPlayerFromCharacter(hit.Parent) print(p:GetPlayerFromCharacter(hit.Parent)) -- This should work. Unless I screwed it up somehow. end)
The reason I did this: loops aren't really needed if you're trying to connect whoever touched the part... You'll have to add debounce to this, and that is probably something you know. Just make it a function, it saves script lag and various other things.. And it'll allow you to do more.