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:

01local debouce = false
02    local gui = game.ReplicatedStorage.EasyGUI
03    local frame = gui.Frame
04 
05    local function onTouched(hit)
06        if not debouce then
07            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
08            if player then
09                if player.PlayerGui:FindFirstChild("EasyGUI") == nil then
10                    debounce = true
11                    local clone = gui:Clone()
12                    local gui2 = clone
13                    local frame2 = gui2.Parent.Frame
14                    clone.Parent = player.PlayerGui
15frame2.Transparency = 1
View all 63 lines...

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

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

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

1local clone = gui:Clone()
2clone.Parent = gui.Parent
3local gui2 = clone
4local frame2 = gui2.Parent.Frame

and that can be simplified to

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

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

1for i = 1, 0, -0.1 do
2    frame2.Transparency = i
3    wait(0.5)
4end
5 
6for i = 0, 1, 0.1 do
7    frame2.Transparency = i
8    wait(0.5)
9end
Ad

Answer this question