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

Admin Commands Gui, Repeating Command, Help please? [closed]

Asked by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

I have previously made a post about this topic that went without a helpful answer (I removed the Question due to this) as to why the script was doing what it was doing, or how I could fix it. The suggestion was to use MouseButton2Click... -_-

Whenever I try to run the message command for the script, when I run it again the command always repeats. Say I run the command once, then it runs once. Except when I run it twice, it runs twice at the same time, same for the third, fourth, fifth, etc. times.

I honestly do not see why the command repeats, and I would like some helpful answer to how to fix this, and what is going wrong. Here is the function for the message command, the command works, except it still has that repeat I do not want.

local core = script.PACCore
--More code, nothing affecting function of problem.
local corclone = core:Clone()
--More code, nothing affecting function of problem.
local data = corclone.Frame.Data
--More code, nothing affecting function of problem.
data.Commands['Message'].MouseButton1Click:connect(function()
            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 = corclone.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 = corclone.Parent.Parent.Name .. ": " .. data.TextInput.TextBox.Text
                game:GetService("Debris"):AddItem(m, wait((m.Text:len()/13)+1))
            end
            table.insert(logs, 1, GetTime() .. " - " .. corclone.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))
            error("Message Command Finished")
            end)
        end)

I would appreciate help with fixing where the script is going wrong, or some clue as to why the function keeps repeating. Thank you.

If you would like to see the issue yourself you can take a look at it in Test Site, the Message command is the only one I have coded so far. Once again, I would appreciate some help, and thank you in advance.

0
Wait, I figured it out, let me post in to the answer field. adark 5487 — 10y

Locked by M39a9am3R and Shawnyg

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Lines 15-41 connects a function that is called every time you click the send button. These lines are repeatedly called when the Message command box is clicked, and thus the multiple function connections.

Remove the end) on line 41, and change line 15 to:

data.TextInput.Confirm.MouseButton1Click:wait()
0
Alright, so if I were to implement a cancel button to cancel a command how would I stop the wait so the message won't appear twice? M39a9am3R 3210 — 10y
0
Never mind, I deleted and replaced the Confirm button whenever I canceled the command, but thank you so much for the help. M39a9am3R 3210 — 10y
Ad