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

If player is in Region3?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago

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
0
This leads to it being false all the time after being in the region. PancakeChop 35 — 9y
0
Yes, that's what you asked for. CodingEvolution 490 — 9y
0
Yeah but now it won't become true anymore when in region. PancakeChop 35 — 9y
0
I updated the answer. Try that. CodingEvolution 490 — 9y
View all comments (3 more)
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 PancakeChop 35 — 9y
0
I'll look more into Region3 and explain more in detail. I haven't used it in a while. CodingEvolution 490 — 9y
0
Alright thank you PancakeChop 35 — 9y
Ad

Answer this question