I’ve been trying to get this to work for about an hour, and i cant for some reason.
my team is blue, the lower and upper corner is in a folder named Region3Test, i am on team blue, the screengui is in startergui, the screengui is called screengui, the frame is called TeamFrame, there is a text label in the frame that says hi, here is my code.
local myRegion = Region3.new(workspace.Region3Test.LowerCorner.Position, workspace.Region3Test.UpperCorner.Position)
local player = game:GetService("Players").LocalPlayer
local UI = player.PlayerGui:WaitForChild9("ScreenGui")
local isInside = false
game:GetService("RunService").Heartbeat:Connect(function()
local humanoid = workspace:FindPartsInRegion3WithWhiteList(myRegion, {script.Parent.HumanoidRootPart})
if #humanoid > 0 and player.Team == game:GetService("Teams")["Blue"] then
print("Teammate found!")
if not (UI.TeamFrame.Visible) then
UI.TeamFrame.Visible = true
end
else
if (UI.TeamFrame.Visible) then
UI.TeamFrame.Visible = false
end
end
end)
thank you, but my foolishness created that error recently so it was not the problem. i fixed it and even copied the code daslick provided and it didnt solve the problem. i have:
-the code in a local script, in starter character scripts
-parts named LowerCorner and UpperCorner in a folder named Region3Test in the workspace
-my team is called Red and i am on that team, i replaced “myTeam” with Red and it didn’t work
-the gui is called ScreenGui and the frame that is a child of the gui is TeamFrame and this is in startergui
local TeamGui = game.ReplicatedStorage:WaitForChild("TeamGui", math.huge)
local Player = game.Players.LocalPlayer
local Lower = game.Workspace.Region3Test.LowerCorner
local Upper = game.Workspace.Region3Test.UpperCorner
local min = Lower.Position - (0.5 * Lower.Size)
local max = Upper.Position + (0.5 * Upper.Size)
local Region = Region3.new(min, max)
local VisualizePart = false
if VisualizePart then
local Visualize = Instance.new("Part", workspace)
Visualize.Anchored = true
Visualize.Transparency = 0.5
Visualize.Color = Color3.fromRGB(255,0,0)
Visualize.CanCollide = false
Visualize.Size = Region.Size
Visualize.CFrame = Region.CFrame
end
local LastGui = nil
while true do
wait()
local Parts = game.Workspace:FindPartsInRegion3WithIgnoreList(Region, {Upper, Lower}, math.huge)
local IsIn = false
for i,v in pairs(Parts) do
local PlayerCharacter = Player.Character or Player.CharacterAdded:Wait()
if PlayerCharacter and v.Name == "HumanoidRootPart" and Player.Team == game:GetService("Teams")["Red"] then
if v.Parent == PlayerCharacter then
IsIn = true
end
end
end
if IsIn then
if LastGui == nil then
local NewGui = TeamGui:Clone()
NewGui.Parent = Player.PlayerGui
LastGui = NewGui
end
else
if LastGui then LastGui:Destroy() LastGui = nil end
end
end