Trouble with regional gui

Yes, the part 2 video is correct.

I’ve adapted it to the screenshot you sent above. To help me debug any errors I recommend you enable the console output in view > output. Anyways, here is the script:

local function isInside(position1, position2, size2)
	return (position1.X >= position2.X - size2.X / 2 and position1.X <= position2.X + size2.X / 2) and -- X Axis
		(position1.Y >= position2.Y - size2.Y / 2 and position1.Y <= position2.Y + size2.Y / 2) and -- Y Axis
		(position1.Z >= position2.Z - size2.Z / 2 and position1.Z <= position2.Z + size2.Z / 2)
end

local title = script.Parent.Title

local seconds = 1 -- TIME IN SECONDS YOU WANT IT TO TAKE FOR THE TEXT LABEL TO REACH ITS GOAL.

local area = game:GetService("Workspace").Area.Area
local debounce = false

while true do task.wait()
	local plr = game:GetService("Players").LocalPlayer
	local char = plr.Character or plr.CharacterAdded:Wait()
	if isInside(char.PrimaryPart.Position, area.Position, area.Size) and not debounce then
		debounce = true
		print("Player in zone.")
		title.Visible = true
		title.Parent.Enabled = true
		game:GetService("TweenService"):Create(title,TweenInfo.new(seconds),{TextTransparency = 0}):Play()
		wait(seconds+1)
		game:GetService("TweenService"):Create(title,TweenInfo.new(seconds),{TextTransparency = 1}):Play()
	elseif not isInside(char.PrimaryPart.Position, area.Position, area.Size) and debounce then
		debounce = false
		game:GetService("TweenService"):Create(title,TweenInfo.new(seconds),{TextTransparency = 1}):Play()
		print("Player outside zone.")
	end
end

For some reason, your code isn’t working in my game though. Can you fix it so it can be where my stuff is positioned in workspace or starter gui? That might be the problem but I’m not sure.

Can you show me if there are any errors in the console? Press F9

Screenshot 2022-08-08 111721
All it shows is that and the text does not show up at all.

It’s supposed display the text “Area” but nothing shows up at all. I don’t know how else to say it.

Can you show a screenshot of the properties of the ScreenGui and the TextLabel?

wooooooow why is a simple question taking this long to figure out? dont use kanoworlds script, you dont need a never ending loop that will create unnecessary lag.
just use the ZonePlus module to detect when a player enters and leaves a zone then simply create a tween to fade in or fade out a gui.
you dont have to reinvent the wheel, especially when you’re a beginner.

1 Like

ZonePlus was mentionned above but OP didn’t want to use it.

The reason why I don’t want to use zoneplus is because I already made a zone which is a part and I have no idea how to use zoneplus.



1st one is screengui last 2 are textlabel

the best way to do this is using ZonePlus, which is a module
simply pass in your part, which you want to be a “zone” and you can easily detect when a player comes in or out, without any hassle or lag
for more info on modules: ModuleScript | Roblox Creator Documentation

I have finally understood my problem. The problem is the text is “” (blank) so yes my script was indeed working correctly its just that setting the textransparency when there is no text is useless. This should work better:

local function isInside(position1, position2, size2)
	return (position1.X >= position2.X - size2.X / 2 and position1.X <= position2.X + size2.X / 2) and -- X Axis
		(position1.Y >= position2.Y - size2.Y / 2 and position1.Y <= position2.Y + size2.Y / 2) and -- Y Axis
		(position1.Z >= position2.Z - size2.Z / 2 and position1.Z <= position2.Z + size2.Z / 2)
end

local title = script.Parent.Title

local seconds = 1 -- TIME IN SECONDS YOU WANT IT TO TAKE FOR THE TEXT LABEL TO REACH ITS GOAL.

local area = game:GetService("Workspace").Area.Area
local debounce = false

while true do task.wait()
	local plr = game:GetService("Players").LocalPlayer
	local char = plr.Character or plr.CharacterAdded:Wait()
	if isInside(char.PrimaryPart.Position, area.Position, area.Size) and not debounce then
		debounce = true
		print("Player in zone.")
		title.Visible = true
		title.Parent.Enabled = true
		title.Text = "Cool Area"
		game:GetService("TweenService"):Create(title,TweenInfo.new(seconds),{TextTransparency = 0}):Play()
		wait(seconds+1)
		game:GetService("TweenService"):Create(title,TweenInfo.new(seconds),{TextTransparency = 1}):Play()
	elseif not isInside(char.PrimaryPart.Position, area.Position, area.Size) and debounce then
		debounce = false
		game:GetService("TweenService"):Create(title,TweenInfo.new(seconds),{TextTransparency = 1}):Play()
		print("Player outside zone.")
	end
end

Edit: I still recommend to use ZonePlus as @a19_9 mentionned.

heres an example of how you’d use zoneplus, its pretty simple. just get the model and put it in replicatedstorage.
image
make our gui
image

then write your script

local zoneModule = require(game.ReplicatedStorage.Zone)

local myPart = workspace.Part

local myNewZone = zoneModule.new(myPart)

myNewZone.playerEntered:Connect(function(playerThatEntered)
	print("A player has entered the zone, this is his name: " .. playerThatEntered.Name)
	playerThatEntered.PlayerGui.ZoneGui.Enabled = true
end)

myNewZone.playerExited:Connect(function(playerThatLeft)
	print("A player has exited the zone, this is his name: " .. playerThatLeft.Name)
	playerThatLeft.PlayerGui.ZoneGui.Enabled = false
end)

and here’s the result: https://gyazo.com/63b635134e689f426ba3eb902871b745
you can pair it up with tweening to achieve your fading effect.

1 Like

this works but when im not even in the zone it says im in the zone and the text pops up. any fixes or is that just how it’s gonna be like? because with my code that i used before it didnt trigger when i wasnt even in the zone.

is there any way you could help me create this but with a zone where it plays sound when you enter it and then stops when it leaves and when you go in and out it does it basically?

because i have something where it does this but it’s just coded differently and doesnt use zoneplus you can scroll up to find the code for it

sure, create a new sound then place it in a gui to be 2D or place it in a part to be 3D
in your script when a player enters the zone, do: Sound:Play()
and when the player leaves do: Sound:Stop()

your code doesnt work still and it never has lol i just dont want to keep having errors so i suggest for you to stop helping because this is a waste of time

could you show the script of how to do it? also before you do if you decide to, I don’t want a gui to show up for the song, i just want the song to play when you enter and stop when you leave and when you’re in the zone i want it to loop.