#pls help with making guis fade in when i toutch a part

1 messages · Page 1 of 1 (latest)

unkempt hull
#

i want to make like a zone system that makes a gui shade in when i enter it but i dont know how to script
so pls tell me if you know how i could do it

forest star
#

I know how

unkempt hull
#

How ?

forest star
#
  1. Where to move everything
    To make this work cleanly, to set up in Explorer like this:
    • Workspace: Place the "Zone Part" here. Name it ZonePart.
    • StarterGui: Place the ScreenGui here.
    • Frame: Inside the ScreenGui (this is what will fade).
    • LocalScript: Put the script inside this Frame.
  2. The Script (The "How")
    You should use TweenService. This is the professional way to "fade" things rather than using a messy loop. Copy and paste this
#

local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local frame = script.Parent -- The script is inside the Frame

local zonePart = workspace:WaitForChild("ZonePart") -- Change this to his part's name

-- Settings for the fade
local info = TweenInfo.new(0.5) -- 0.5 seconds to fade
local fadeIn = TweenService:Create(frame, info, {BackgroundTransparency = 0})
local fadeOut = TweenService:Create(frame, info, {BackgroundTransparency = 1})

-- Make sure it starts invisible
frame.BackgroundTransparency = 1

zonePart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
if game.Players:GetPlayerFromCharacter(character) == player then
fadeIn:Play()
end
end
end)

zonePart.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
if game.Players:GetPlayerFromCharacter(character) == player then
fadeOut:Play()
end
end
end)

#
  1. Why move it there?
    If you asks why the script goes in StarterGui and not the Part:
    • LocalScripts only run if they are in places like StarterGui or StarterPlayerScripts.
    • If you puts a regular Script in the Part, the GUI will fade for everyone on the server at the same time, which would be very annoying for other players!
  2. Pro-Tip for you
    If your zone" is a big room, .Touched can sometimes be glitchy (it might flicker). If that happens, look into a plugin called ZonePlus, which is what most pro developers use for zone systems.
acoustic quiver
#

use zonesplus

forest star
unkempt hull
#

Idk i didnt try yet

#

I went to sleep

#

But im gonna try it

unkempt hull
#

oh yeah i forgot about that

#

but yeah anyways i gave up on my game

#

cuz i got hire for a bigger game

#

with way more devs

#

so thx but i actually dont need it anymore

unkempt hull
#

actually i had to use it and it doesnt work

#

cuz if i move on the part it just blinks