Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

gui not inserting into playergui and not fading? ( 'attempt to index nil with 'Frame')

my script here is:

local debouce = false
	local gui = game.ReplicatedStorage.EasyGUI
	local frame = gui.Frame
	 
	local function onTouched(hit)
	    if not debouce then
	        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	        if player then
	            if player.PlayerGui:FindFirstChild("EasyGUI") == nil then
	                debounce = true
	                local clone = gui:Clone()
                    local gui2 = clone
                    local frame2 = gui2.Parent.Frame
	                clone.Parent = player.PlayerGui
frame2.Transparency = 1
wait(0.1)
frame2.Transparency = 0.9
wait(0.1)
frame2.Transparency = 0.8
wait(0.1)
frame2.Transparency = 0.7
wait(0.1)
frame2.Transparency = 0.6
wait(0.1)
frame2.Transparency = 0.5
wait(0.1)
frame2.Transparency = 0.4
wait(0.1)
frame2.Transparency = 0.3
wait(0.1)
frame2.Transparency = 0.2
wait(0.1)
frame2.Transparency = 0.1
wait(0.1)
frame2.Transparency = 0
wait(2)
frame2.Transparency = 0.1
wait(0.1)
frame2.Transparency = 0.2
wait(0.1)
frame2.Transparency = 0.3
wait(0.1)
frame2.Transparency = 0.4
wait(0.1)
frame2.Transparency = 0.5
wait(0.1)
frame2.Transparency = 0.6
wait(0.1)
frame2.Transparency = 0.7
wait(0.1)
frame2.Transparency = 0.8
wait(0.1)
frame2.Transparency = 0.9
wait(0.1)
frame2.Transparency = 1
	                wait(1.5)
                    gui2:Destroy()
	                debouce = false
	            end
	        end
	    end
	end
	script.Parent.Touched:Connect(onTouched)

thank you,

-Dexiber

1 comment

0

just to help you out, a for loop would keep you from doing all that list of transparency.

1 answer

✓ Accepted answer

The problem is in

local clone = gui:Clone()
local gui2 = clone
local frame2 = gui2.Parent.Frame

When you clone something, it exists only in memory until you define its parent. Do this:

local clone = gui:Clone()
clone.Parent = gui.Parent
local gui2 = clone
local frame2 = gui2.Parent.Frame

and that can be simplified to

local gui2 = gui:Clone()
gui2.Parent = gui.Parent
local frame2 = gui2.Parent.Frame

And for your transparency list, you can use a simple for loop:

for i = 1, 0, -0.1 do
	frame2.Transparency = i
	wait(0.5)
end

for i = 0, 1, 0.1 do
	frame2.Transparency = i
	wait(0.5)
end
	

This discussion is preserved as it was. New answers, comments, and votes are closed.