######had to trim the title quite a bit edit: where are all the comments and answers why do i have only one dude who has commented and answered this
local debounce = false
script.Parent.Touched:Connect(function(otherPart)
local player = game:GetService("Players"):GetPlayerFromCharacter(otherPart.Parent)
if player and not debounce then
debounce = true
game:GetService("ReplicatedStorage").TouchEvent:FireClient(player, script.Parent)
script.Parent.TouchEnded:Wait()
wait(1)
debounce = false
end
end)
hold up
what's that I see?
huhr?
i can't read it
lets zoom in
#script.Parent.TouchEnded:Wait()
ok let's be serious now
You'd think, "ey this'll work perfectly"
Well, until you pay attention to this:
##players have multiple parts
Soo...
What's the best way to get when the player actually stops touching the part?
######only revert to player:GetDistanceFromCharacter(script.Parent.Position) if it's the only way out ######and note: plz make sure u include how 2 do it with R15
EDIT: I figured it out, you just have to use :GetTouchingParts() and check if the parents of any of the given values are the player's Character. I will keep this question hanging around so that others can see.
local debounce = true
script.Parent.Touched:Connect(function(otherPart)
local player = game:GetService("Players"):GetPlayerFromCharacter(otherPart.Parent)
if player and debounce then
debounce = false
game:GetService("ReplicatedStorage").TouchEvent:FireClient(player, script.Parent)
local function waitUntilNoMoreCollision() -- importent
while true do
local s = false -- importent
for i,v in pairs(script.Parent:GetTouchingParts()) do -- importent
if v.Parent == player.Character then -- importent
s = true -- importent
end
end
if not s then -- importent
print("Player stopped touching!")
return -- importent
end
wait() -- ultra importent
end
end
waitUntilNoMoreCollision() -- importent
debounce = true
end
end)

5 comments
Err... no. Won't make a difference, for as I mentioned in the question: PLAYERS. HAVE. MULTIPLE. PARTS.
and dose parts be MOVING
When you say multiple parts what do you mean, because R15 uses multiple parts already, and that works perfect for me
When you say multiple parts what do you mean, because R15 uses multiple parts already, and that works perfect for me
err... the parts go back and forth and it easily triggers the TouchEnded event with one part and then another part re-triggers the Touched event