Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Dexiber 272 Moderation Voter
4 years ago
Edited 4 years ago

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

0
just to help you out, a for loop would keep you from doing all that list of transparency. Necro_las 412 — 4y

1 answer

Log in to vote
1
Answered by
Necro_las 412 Moderation Voter
4 years ago

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

Ad

Answer this question