Im planning on making an area title drop down whenever you touch an invisible noncollideable part.
The key result is for when i enter the part, the gui drops down once. and only once, and then when i leave the part then come back to it again, it appears, but for me its not working at all! I tried multiple functions but it just wont come to me.
-- Replace "Part" with the name of your non-collidable part
local nonCollideablePart = game.Workspace.AreaTitles["Crash Site"]
-- Replace "Gui" with the name of your GUI element
local gui = game.Players.LocalPlayer.PlayerGui.AreaTitles
local frame = gui.Frame
-- Replace "TweenInfo.new(1)" with your preferred tween duration and easing style
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
-- Replace "areaName" with the name of the area you want to display
local areaName = "Crash Site"
local description = "A small island with a single eggdog and the wreckage of a space shuttle."
-- Create the tweens
local guiTweenShow = game:GetService("TweenService"):Create(frame, tweenInfo, {Position = UDim2.new(0, 0, 0, 0)})
local guiTweenHide = game:GetService("TweenService"):Create(frame, tweenInfo, {Position = UDim2.new(0, 0, -1, 0)})
local delayTime = 3 -- Replace with the number of seconds you want to delay before hiding the GUI
local debounce = false
-- Function to display the GUI and start the tween
local function showAreaName()
if debounce == false and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild("Humanoid") and nonCollideablePart:IsTouching(game.Players.LocalPlayer.Character.Humanoid) then
debounce = true
frame.Back.AreaTitle.Text = areaName
frame.Back.Description.Text = description
guiTweenShow:Play()
wait(delayTime)
guiTweenHide:Play()
wait(1)
debounce = false
end
end
-- Connect the show function to the non-collidable part's touch event
nonCollideablePart.Touched:Connect(showAreaName)
