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

Script breaks and glitches out for no forseeable reason?

Asked by
drew1017 330 Moderation Voter
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
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.

0
Could you post your whole script? Shawnyg 4330 — 9y
0
Done. drew1017 330 — 9y
0
Make sure you copied the exact coordinates as in studio. marcoantoniosantos3 200 — 9y
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. drew1017 330 — 9y
View all comments (2 more)
0
'b = game.Players.LocalPlayer.Name' doesn't make sense. Use variables the represent what they equal. For example, 'name = game.Players.LocalPlayer.Name' Perci1 4988 — 9y
0
^ i dont think thats necessary if the variable is only used for 1 thing drew1017 330 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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

0
Made it stop making the error, but problem 1 and 2 are still there. drew1017 330 — 9y
0
The error 1? I'm sure its due LUA patterns. Let me edit it for ya marcoantoniosantos3 200 — 9y
0
It still just prints ''1 Player1''. Additionally, none of the code after that runs, even though there's no error. drew1017 330 — 9y
Ad

Answer this question