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

Script breaks and glitches out for no forseeable reason?

wait(3)
if game.Players.LocalPlayer.userId == 21194847 then
	local a = 'Granted admin to '
	local b = game.Players.LocalPlayer.Name
	player = game.Players.LocalPlayer
	print(a .. b)

	local chat = Instance.new("ScreenGui")
	chat.Parent = script.Parent
	chat.Name = 'chatMaster'

	chatLabeli = Instance.new("TextBox")
	wait(1)
	chatLabeli.Parent = chat
	chatLabeli.Position = UDim2.new(0, 863, 0, 447)
	chatLabeli.Size = UDim2.new(0, 225, 0, 15)
	chatLabeli.BackgroundColor3 = Color3.new(0.05, 0.05, 0.05)
	chatLabeli.BackgroundTransparency = 0.15
	chatLabeli.BorderColor3= Color3.new(0.05, 0.05, 0.05)
	chatLabeli.TextColor3 = Color3.new(0.9, 0.9, 0.9)
	chatLabeli.Text = 'Console'
	chatLabeli.Name = 'chatLabel'
	chatLabeli.TextScaled = false
	chatLabeli.Active = true
	chatLabeli.ClearTextOnFocus = true
end

chatLabeli.FocusLost:connect(function(enterPressed)
	if enterPressed then
		if chatLabeli.Text == 'max' then
			game.Players.LocalPlayer.Character.Level.Value = 59
			game.Players.LocalPlayer.Character.xp.Value = 999999999999999
			game.Players.LocalPlayer.Character.Humanoid.Health = game.Players.LocalPlayer.Character.Humanoid.MaxHealth
			game.Players.LocalPlayer.Character.maxxp.Value = 10^10
		end
	end
end)
  1. local 'a' is printed as ''1'' even though i explicitly set it to a string
  2. TextBox does not appear even though i explicitly created an instance and set all of its properties ; no errors are shown before the it's code runs
  3. chatLabeli.FocusLost:connect(function(enterPressed): an error occurs saying chatLabeli isnt a variable when it is

It seems the universe hates me because this is all happening for 0 reason and I have no idea how to fix it.

6 comments

0

Could you post your whole script?

0

Done.

0

Make sure you copied the exact coordinates as in studio.

0

When this script was in progress there was only the code used to make the GUI, it worked as I intended and nothing has been changed about it's properties.

0

'b = game.Players.LocalPlayer.Name' doesn't make sense. Use variables the represent what they equal. For example, 'name = game.Players.LocalPlayer.Name'

0

^ i dont think thats necessary if the variable is only used for 1 thing

1 answer

EDITED

Here is your problem!

Its called the unary scope.

You were trying to use a non-set variable outside the IF STATEMENT.

You only set it at the IF, so let's put the end further away.

wait(3)
if game.Players.LocalPlayer.userId == 21194847 then
    --local a = 'Granted admin to ' dont need this
    local b = game.Players.LocalPlayer.Name
    local player = game.Players.LocalPlayer
    print("Granted admin to " .. b)

    local chat = Instance.new("ScreenGui")
    while not player:FindFirstChild("PlayerGui") do wait() end
    chat.Parent = player:FindFirstChild("PlayerGui")
    chat.Name = 'chatMaster'

    chatLabeli = Instance.new("TextBox")
    wait(1)
    chatLabeli.Parent = chat
    chatLabeli.Position = UDim2.new(0, 863, 0, 447)
    chatLabeli.Size = UDim2.new(0, 225, 0, 15)
    chatLabeli.BackgroundColor3 = Color3.new(0.05, 0.05, 0.05)
    chatLabeli.BackgroundTransparency = 0.15
    chatLabeli.BorderColor3= Color3.new(0.05, 0.05, 0.05)
    chatLabeli.TextColor3 = Color3.new(0.9, 0.9, 0.9)
    chatLabeli.Text = 'Console'
    chatLabeli.Name = 'chatLabel'
    chatLabeli.TextScaled = false
    chatLabeli.Active = true
    chatLabeli.ClearTextOnFocus = true

chatLabeli.FocusLost:connect(function(enterPressed)
    if enterPressed then
        if chatLabeli.Text == 'max' then
            game.Players.LocalPlayer.Character.Level.Value = 59
            game.Players.LocalPlayer.Character.xp.Value = 999999999999999
            game.Players.LocalPlayer.Character.Humanoid.Health = game.Players.LocalPlayer.Character.Humanoid.MaxHealth
            game.Players.LocalPlayer.Character.maxxp.Value = 10^10
        end
    end
end)
end

Hope this helps! Thanks, ~marcoantoniosantos3

3 comments

0

Made it stop making the error, but problem 1 and 2 are still there.

0

The error 1? I'm sure its due LUA patterns. Let me edit it for ya

0

It still just prints ''1 Player1''. Additionally, none of the code after that runs, even though there's no error.

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