#pls help with making guis fade in when i toutch a part
1 messages · Page 1 of 1 (latest)
I know how
How ?
- 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. - 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)
- 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! - 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.
use zonesplus
Ok ill try it thx
Did it work?