Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is it possible to track if a player is standing on a part, and when it steps off?

Asked by 10 years ago

I am trying to make a platform that checks if multiple players are touching at the same time. What is the simplest way to do that? This is pretty much all I have l:

1platform.Touched:connect(function(hit)
2    local player  = hit.Parent
3    if player.Character:FindFirstChild("RobberMatchTag") then
4        local robber = player
5 
6    end
7end)

1 answer

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
10 years ago

All you would need to do, is something like this:

01Touching={}
02 
03platform.Touched:connect(function(hit)
04    local Valid=true
05    local player = hit.Parent
06    if player.Character:FindFirstChild("RobberMatchTag") then
07        local robber = player
08        for i=1, #Touching do
09            if Touching[i]==robber then --Checks if players already touching
10                Valid=false
11            end
12        end
13        if Valid==true then
14            Touching[#Touching+1]=robber
15        end
View all 28 lines...

I think this should work. If you have any problems please leave a comment below. Hope I helped :P

1
Thank you for a really quick answer! :D SonioSony 53 — 10y
1
No prob, glad I could help :P dyler3 1510 — 10y
Ad

Answer this question