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

2+ Players on a Touched Event?

Asked by 5 years ago

I'm wanting to have 2+ players who can stand on a floor and earn money once every second. I need to know what function/event/whatever I can use to accomplish this. Any help is appreciated.

1
Use a Region3 instead to get the players inside of the region. xPolarium 1388 — 5y
0
You could use magnitude to hellmatic 1523 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I did something similar to this once with Touched instead of Region3s. The way I did it was by using tables.

Here's a quick example:

local trigger = workspace.Part
local players = {}

trigger.Touched:Connect(function(part)
    local plr = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
    if plr then
        for i,v in pairs(players) do
            if v ~= plr.Name then
                table.insert(players,plr.Name)
            end
        end
    end
end)

trigger.TouchEnded:Connect(function(part)
    local plr = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
    if plr then
        for i,v in pairs(players) do
            if v == plr.Name then
                table.remove(players[i])
            end
        end
    end
end)

Then you can just determine who's on the part based on the values in the table

0
The problem with that is I need to detect when the player is in the area...when the player jumps(inside the brick) the touchended is run, i need that to not happen. ForeverBrown 356 — 5y
0
I do plan to work with Region3 though ForeverBrown 356 — 5y
Ad

Answer this question