Hello, I saw the shop circle on some simulators where when you enter it shop pops up and when you leave it it dissapears, I simply want to ask how to know when a player enters and leaves a certain area.
They probably either have a feedback loop or use a module like ZonePlus:
ive tried using it and it doesn’t print? do i need to put it inside a local script?
Touch events works acceptable, Touched
and TouchEnded
, a very simple approach would be creating a cylinder part, invisible, no collidable, and listen to those events to open and close the GUI
Would have to disagree with using TouchEnded, a region check would be better since Touched and TouchEnded aren’t perfect, and usually bugs out at times.
You can use a loop every frame and check the distance in magnitude.
WorldRoot region3 functions are deprecated.
while true do
local box = workspace:GetPartsInPart(workspace.TouchPart)
for i, v in pairs(box) do
if game.Players:GetPlayerFromCharacter(v.Parent) ~= nil then
local player = game.Players:GetPlayerFromCharacter(v.Parent)
player.PlayerGui:WaitForChild("gui-name")["frame-name"].Visible = false
end
end
wait()
end
Neither did I mention Region3, I said region, which refers to a particular area or part in the game.
I want it to disappear when you leave the brick.
If it’s a circle you can get away with using the distance between it and the player’s humanoid root. This is a rough example of what you’d like to do
local rootPartPosition = player.HumanoidRootPart.Position
local origin = Part.Position
local radius = 15 -- How big the circle is
local debounce = false
local distance = (origin - rootPartPosition).Magnitude
function runService()
if distance > radius then debounce = false return end
if debounce then return end
debounce = true
--Shop code here
end
runService.Heartbeat:Connect(runService)
This works, but prob shouldn’t use while true do.
In the video he does that i think at 6 minute
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.