0

# How would I detect player movment inside a part?

I want to know how to detect player movement inside a part, but the only way I know how to do this all the players will get detected if one player move's, I would like to know if a player were to walk into a part with multiple people only that person will get detected.

0

I am half asleep so I have no idea if this will work with multiple people.

So I put a server script inside of the desired part and a folder called PlayersOnPart

The script inside of the part

local Players = game:GetService("Players")
local Main = script.Parent

local Range = 40
local Check = true
local stop = 15

local function balls()
for _,Player in next, Players:GetPlayers() do
local char = Player
local name = char.Name
if script.Parent.PlayersOnPart:FindFirstChild(name)then
wait()
elseif not script.Parent.PlayersOnPart:FindFirstChild(name) then
local namedong = Instance.new("BoolValue",script.Parent.PlayersOnPart)
namedong.Name = name
end
end
end

local function noballs()
for _,Player in next, Players:GetPlayers() do
local char = Player
local name = char.Name
if script.Parent.PlayersOnPart:FindFirstChild(name) then
script.Parent.PlayersOnPart:FindFirstChild(name):Remove()
end
end

end
while wait() and Check do
for _,Player in next, Players:GetPlayers() do
local Char = Player.Character or Player.CharacterAdded:wait()
local HumanoidRootPart = Char:FindFirstChild('HumanoidRootPart')
local A,B = HumanoidRootPart.Position, Main.Position

local Dist = (A - B).Magnitude
if stop >= Dist then
balls()
else
noballs()
end
end
end



if its confusing or if it doesn't work tell me tomorrow cause I'm so tired.

There is also a script inside of the workspace that gets the amount of players, I made it so it named the players inside of the part so if you wanna do anything with that go ahead, but here is the script for now.

local Folder = script.Parent.Part3.PlayersOnPart

while true do
wait(1)
print(#Folder:GetChildren())
end



Next time you ask a question try doing it yourself first or show some code of what you tried to do. Anyways gl with you game