Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

2+ Players on a Touched Event?

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.

2 comments

1

Use a Region3 instead to get the players inside of the region.

0

You could use magnitude to

1 answer

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

2 comments

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.

0

I do plan to work with Region3 though

This discussion is preserved as it was. New answers, comments, and votes are closed.