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

If player is in Region3?

So when the player is in the Region, a Gui becomes visible, but would I have to do to make it false when not in the Region?

region = Region3.new(Vector3.new(0,0,0), Vector3.new(10,10,10))
p = Instance.new("Part",game.Workspace)
p.Name = "Region"
p.Size = region.Size
p.CFrame = region.CFrame
p.Transparency = 1
p.CanCollide = false

while wait() do
for i,v in pairs(game.Workspace:FindPartsInRegion3(region,nil,100)) do
if v.Name == "Torso" then
print (v.Parent.Name)
game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Visible = true
end
end
end

1 answer

Create an else statement and be a bit more specific finding the player rather than using "Torso"

local player = game:GetService("Players").LocalPlayer
region = Region3.new(Vector3.new(0,0,0), Vector3.new(10,10,10))
p = Instance.new("Part",workspace)
p.Name = "Region"
p.Size = region.Size
p.CFrame = region.CFrame
p.Transparency = 1
p.CanCollide = false

while wait() do
	for i,v in pairs(workspace:FindPartsInRegion3(region,nil,100)) do
		player.PlayerGui.ScreenGui.TextLabel.Visible = false
		if v.Name == "Torso" and v.Parent.Name==player.Name then
			print (v.Parent.Name)
			player.PlayerGui.ScreenGui.TextLabel.Visible = true
		end
	end
end

7 comments

0

This leads to it being false all the time after being in the region.

0

Yes, that's what you asked for.

0

Yeah but now it won't become true anymore when in region.

0

I updated the answer. Try that.

0

It didn't work, I believe I'm gonna have to understand the following to do this: http://wiki.roblox.com/index.php?title=ContextActionService_tutorial

0

I'll look more into Region3 and explain more in detail. I haven't used it in a while.

0

Alright thank you

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