Im not talking about to change :Connect to :Once im talking about how do i make each player touch the part only once and still use :Connect
1 Like
This is quite confusing, mind showing the code you currently have and pointing out what’s wrong with it?
1 Like
local part = somepart
local connection
connection = Part.Touched:connect(function(touch)
local char = touch:FindFirstAncestorWhichIsA("Model")
local plr = game.Players:GetPlayerFromCharacter(Char)
if nil == plr then return end
print(plr.Name.." touched. Disconnecting touch connection.")
connection:Disconnect()
end
2 Likes
The indents are weird because I typed it on my phone
Or like this where each player can touch once
local part = somepart
local alreadytouched = {}
Part.Touched:connect(function(touch)
local char = touch:FindFirstAncestorWhichIsA("Model")
local plr = game.Players:GetPlayerFromCharacter(Char)
if nil == plr or table.find(alreadytouched, plr) then return end
table.insert(alreadytouched, plr)
print(plr.Name.." touched. Adding them to touch blacklist.")
end
3 Likes
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.