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

Why does my waitforchild script not work and why is there another issue (no error)?


ChatGui = game.Players:WaitForChild("DevSeveral").DevSeveral.PlayerGui
Part = script.Parent

Part.ClickDetector.MouseClick:Connect(function(pussy2)
	Part.BrickColor = BrickColor.new("Bright yellow")
	Part.Anchored = true
	Part.Transparency = .2
	wait(2)
	ChatGui:Remove()
	wait(2)
	if Part.BrickColor == ("Bright yellow") then
		print('Part is bright yellow')
		wait(.01)
		print('Changing...')
		Part.BrickColor = BrickColor.new("Alder")
	end
end)

For first script issue error: DevSeveral is not a valid member of Player

For second script issue error: There is none

The first line gets an error and I do not believe the waitforchild is working, also the script:

if Part.BrickColor == ("Bright yellow") then
		print('Part is bright yellow')
		wait(.01)
		print('Changing...')
		Part.BrickColor = BrickColor.new("Alder")
	end

Won't work

1 answer

Okay, I've noticed four errors in your code.

The first error would be this line here:

ChatGui = game.Players:WaitForChild("DevSeveral").DevSeveral.PlayerGui

The error is that you added an additional .DevSeveral. Anoterh thing is that this is the PlayerGUI, not your ChatGui.

I changed it by doing:

local ChatGui = game.Players:WaitForChild("DevSeveral").PlayerGui["GUINAMEGOESHERE"]

Another thing is that, on line 9, you did:

ChatGui:Remove()

(remove is depercated as you can see here.)

Try using :Destroy() instead.

Another thing is that on line 11, you did ("Bright yellow") instead of BrickColor.new("Bright yellow")

Full edited script:

local ChatGui = game.Players:WaitForChild("DevSeveral").PlayerGui["GUINAMEGOESHERE"]
local Part = script.Parent

Part.ClickDetector.MouseClick:Connect(function(pussy2)
    Part.BrickColor = BrickColor.new("Bright yellow")
    Part.Anchored = true
    Part.Transparency = .2
    wait(2)
    ChatGui:Destroy()
    wait(2)
    if Part.BrickColor == BrickColor.new("Bright yellow") then
        print('Part is bright yellow')
        wait(.01)
        print('Changing...')
        Part.BrickColor = BrickColor.new("Alder")
    end
end)

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