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

Why does it say button is an invalid member for my screengui?

Hello, im new to creating games and know next to nothing about scripting and i followed a channels instructions on scripting minigames. i am trying to create a fps but was using his tutorial for the intermission, spawn in the map, etc. But everytime i test the game it says:

		13:32:52.939 - Button is not a valid member of ScreenGui

Do you know how to fix this?

--// Tables Winners = {}

--// Modules Settings = require(script.Settings)

--// Game Variables Intermission = Settings.Intermission GameTime = Settings.GameTime

--// Functions function ChangeText(Text) local Players = game.Players:GetPlayers() for i = 1, #Players do Players[i].PlayerGui.Main.Time.Text = Text end end

function GetMap() local Maps = game.ReplicatedStorage.Maps:GetChildren() local PickMap = math.random(1, #Maps) local SelectedMap = Maps[PickMap]:Clone() SelectedMap.Name = 'Map' SelectedMap.Parent = game.Workspace end

function RemoveMap() if game.Workspace:FindFirstChild('Map') then game.Workspace.Map:remove() end end

--// Game while true do for i = Intermission, 0, -1 do ChangeText('Intermission... ' ..i) wait(1) end

local Players = game.Players:GetPlayers()
for i = 1, #Players do
	Players[i].Playing.Value = true
end	

ChangeText('Game Starting...')
wait(2)
GetMap()
wait(1)


local Players = game.Players:GetPlayers()
for i = 1, #Players do
	if Players[i].Playing.Value == true then
		local Spawn = game.Workspace.Map.Spawns.Spawn
		Players[i].Character.Torso.CFrame = CFrame.new(Spawn.Position)
		Spawn:remove()
		Players[i].Character.Humanoid.WalkSpeed = 0
	end
end

ChangeText('Round Starting...')
wait(5)

local Players = game.Players:GetPlayers()
for i = 1, #Players do
	if Players[i].Playing.Value == true then
		Players.Character.Humanoid.Walkspeed = 16
	end
end

ChangeText('Begin!')
wait()

for i = GameTime, 0, -1 do
	ChangeText('GameTime ' ..i)
	wait(1)
end

local Players = game.Players:GetPlayers()
for i = 1, #Players do
	if Players[i].Playing.Value == true then
		table.insert(Winners, Players[i].Name)
		Players[i].leaderstats.Money.Value = Players[i].leaderstats.Money.Value + 75
		Players[i].leaderstats.Wins.Value = Players[i].leaderstats.Wins.Value + 1
		Players[i].Character.Humanoid.Health = 0
		Players[i].Playing.Value = false
	end
end

RemoveMap()
ChangeText('Game Over!')
wait(5)

end

5 comments

0

No one can help you because you show no script, show script for help

0

that help?

0

"Button is not a valid member of ScreenGui" means that in ScreenGui there is no element named "Button"

0

where does it say button?

0

I have also been getting this error. I dont know how to fix this either. 14:14:50.317 - ServerScriptService.Main:21: bad argument #2 to 'random' (interval is empty)

1 answer

Solution 1: Try doing :WaitForChild() on the button and the parent(s)

Solution 2: Instead of going to ScreenGui go to PlayerGui by doing

local player = game.Players.LocalPlayer
local ScreenGui = player.PlayerGui
-- ScreenGui now allows you to go into the PlayerGui

It works for me when I get those errors.

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