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

[ Unsolved ] Admin GUI Script Commands Run Over And Over, Any Help or Advice?

Asked by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

I am making a Admin GUI, but whenever I try testing the Message and Hint commands I keep having problems. They seem to execute at the same time when you go to use the commands again (I know this may sound confusing, I'll explain it).

For instance;

  • I run the message command at first, the message shows, then I use the hint command, and both the message and the hint shows.

  • I run the message command at first, message shows. I use the message command again, and there are two and they overlap. (Same goes for Hints)

If you still don't understand, I have a demo ready at my Test Site

It just resets and does the same thing after you reset as well.

Here's the script I have for trying to run the code;

for _,button in pairs(corclone.Frame.Data.Commands:children()) do
    button.MouseButton1Click:connect(function()
        CommandClicked(button.Text, corclone)
    end)
end

"corclone" is the clone of the CoreGUI which is in the PlayerGUI.

This is the function for "CommandClicked";

function CommandClicked(button, host)
    local data=host.Frame.Data
    local info=host.Frame.Info.Frame
    if button == "Message" then
        data.Commands:TweenPosition(UDim2.new(1, 35, 0, 20), "Out", "Linear", 3/4)
        wait()
        data.TextInput.Visible = true
        data.TextInput:TweenPosition(UDim2.new(0, 35, 0, 20), "Out", "Linear", 3/4)
        wait()
        info.TextLabel.Text = "M:Message"
        info:TweenPosition(UDim2.new(0, 0, 0, -10), "Out", "Linear", 1)
        data.TextInput.Confirm.MouseButton1Click:connect(function()
        if script:FindFirstChild("Message") then
            for _,v in pairs(game:GetService("Players"):GetChildren()) do
                coroutine.resume(coroutine.create(function()
                local m = script.Message:Clone()
                m.Frame.Body.Msg.Text = data.TextInput.TextBox.Text
                m.Frame.Header.Head.Text = host.Parent.Parent.Name
                m.Parent = v:WaitForChild("PlayerGui")
                wait()
                m.Frame.Script.Disabled = false
                end))
            end
        else
            local m = Instance.new("Message",game:GetService("Workspace"))
            m.Text = host.Parent.Parent.Name .. ": " .. data.TextInput.TextBox.Text
            game:GetService("Debris"):AddItem(m, wait((m.Text:len()/13)+1))
        end
        table.insert(logs, 1, GetTime() .. " - " .. host.Parent.Parent.Name .. " messaged, ".. data.TextInput.TextBox.Text)
        data.Commands.Position = UDim2.new(-1, 35, 0, 20)
        data.TextInput:TweenPosition(UDim2.new(1, 35, 0, 20), "Out", "Linear", 3/4)
        wait()
        data.Commands:TweenPosition(UDim2.new(0, 35, 0, 20), "Out", "Linear", 3/4)
        wait()
        info:TweenPosition(UDim2.new(0, 0, -1, -10), "Out", "Linear", 1/2)
        coroutine.resume(coroutine.create(function() wait(1) data.TextInput.Position = UDim2.new(-1, 35, 0, 20) data.TextInput.Visible = false end))
        end)
    elseif button == "Hint" then
        data.Commands:TweenPosition(UDim2.new(1, 35, 0, 20), "Out", "Linear", 3/4)
        wait()
        data.TextInput.Visible = true
        data.TextInput:TweenPosition(UDim2.new(0, 35, 0, 20), "Out", "Linear", 3/4)
        wait()
        info.TextLabel.Text = "H:Message"
        info:TweenPosition(UDim2.new(0, 0, 0, -10), "Out", "Linear", 1)
        data.TextInput.Confirm.MouseButton1Click:connect(function()
        if script:FindFirstChild("Hint") then
            for _,v in pairs(game:GetService("Players"):GetChildren()) do
                coroutine.resume(coroutine.create(function()
                local m = script.Hint:Clone()
                m.Frame.Msg.Text = host.Parent.Parent.Name .. ": " .. data.TextInput.TextBox.Text
                m.Parent = v:WaitForChild("PlayerGui")
                wait()
                m.Frame.Script.Disabled = false
                end))
            end
        else
            local m = Instance.new("Hint",game:GetService("Workspace"))
            m.Text = host.Parent.Parent.Name .. ": " .. data.TextInput.TextBox.Text
            game:GetService("Debris"):AddItem(m, wait((m.Text:len()/13)+1))
        end
        table.insert(logs, 1, GetTime() .. " - " .. host.Parent.Parent.Name .. " hinted, ".. data.TextInput.TextBox.Text)
        data.Commands.Position = UDim2.new(-1, 35, 0, 20)
        data.TextInput:TweenPosition(UDim2.new(1, 35, 0, 20), "Out", "Linear", 3/4)
        wait()
        data.Commands:TweenPosition(UDim2.new(0, 35, 0, 20), "Out", "Linear", 3/4)
        wait()
        info:TweenPosition(UDim2.new(0, 0, -1, -10), "Out", "Linear", 1/2)
        coroutine.resume(coroutine.create(function() wait(1) data.TextInput.Position = UDim2.new(-1, 35, 0, 20) data.TextInput.Visible = false end))
        end)
    end
end

Gosh there should be a spoiler tag.

I just don't get why the Message Command or the Hint Commands keep re-running, if any body has any advice please leave a comment or if you think you know how to fix the problem, answer it. Thank you in advanced. If you wish to see the GUI and check out the problem for yourself then you can go to my Test Site, the Script should automatically give you admin.

1 answer

Log in to vote
-1
Answered by 9 years ago

Try to do mousebutton1down for Message and mousebutton2down for Hint.

0
That would not work, a user would not know to right click on hint and left click on message... M39a9am3R 3210 — 9y
Ad

Answer this question