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

what could I do so the while loop actually loops through the text and not cause an error?

Asked by
oSyM8V3N 429 Moderation Voter
5 years ago
wait(game.Lighting.TimeToLoad.Value)

local UIS = game:GetService("UserInputService")
local p = game.Players.LocalPlayer
chainnum = 0
chain = "None"
chainText = "None"


--//Animations
local combat1 = script:FindFirstChild("Animations").punchOne
local animTrack1 = p.Character.Humanoid:LoadAnimation(combat1)
--
local combat2 = script:FindFirstChild("Animations").punchTwo
local animTrack2 = p.Character.Humanoid:LoadAnimation(combat2)
--
local combat3 = script:FindFirstChild("Animations").punchThree
local animTrack3 = p.Character.Humanoid:LoadAnimation(combat3)
--
local combat4 = script:FindFirstChild("Animations").punchFour
local animTrack4 = p.Character.Humanoid:LoadAnimation(combat4)
--
local combat5= script:FindFirstChild("Animations").punchFive
local animTrack5 = p.Character.Humanoid:LoadAnimation(combat5)
--
local combat6 = script:FindFirstChild("Animations").punchFour
local animTrack6 = p.Character.Humanoid:LoadAnimation(combat6)

local function Combat(Input, gameProcessedEvent)
    local KeyCode = Input.UserInputType

    if KeyCode == Enum.UserInputType.MouseButton1 and script.canAttack.Value == true and chainnum == 0 then
        chainnum = 1
        chainText = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = "L"
        print("1")
        animTrack1:Play()
    --  p.PlayerGui.MainGui.Frame["Ki Frame"].Size  = p.PlayerGui.MainGui.Frame["Ki Frame"].Size  + UDim2.new(.03, 0, 0, 0)
        wait(0.5)
        chainnum = 2

    else
    if KeyCode == Enum.UserInputType.MouseButton1 and script.canAttack.Value == true and chainnum == 2 then
        chainnum = 3
        chainText = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = "L-L"
        print("2")
        animTrack2:Play()
    --  p.PlayerGui.MainGui.Frame["Ki Frame"].Size  = p.PlayerGui.MainGui.Frame["Ki Frame"].Size  + UDim2.new(.03, 0, 0, 0)
        wait(0.5)
        chainnum = 4

    else
    if KeyCode == Enum.UserInputType.MouseButton1 and script.canAttack.Value == true and chainnum == 4 then
        chainnum = 5
        chainText = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = "L-L-L"
        print("3")
        animTrack3:Play()
    --  p.PlayerGui.MainGui.Frame["Ki Frame"].Size  = p.PlayerGui.MainGui.Frame["Ki Frame"].Size  + UDim2.new(.03, 0, 0, 0)
        wait(0.5)
        chainnum = 6

    else
    if KeyCode == Enum.UserInputType.MouseButton1 and script.canAttack.Value == true and chainnum == 6 then
        chainnum = 7
        chainText = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = "L-L-L-L"
        print("4")
        animTrack4:Play()
    --  p.PlayerGui.MainGui.Frame["Ki Frame"].Size  = p.PlayerGui.MainGui.Frame["Ki Frame"].Size  + UDim2.new(.03, 0, 0, 0)
        wait(0.5)
        chainnum = 8

    else
    if KeyCode == Enum.UserInputType.MouseButton1 and script.canAttack.Value == true and chainnum == 8 then
        chainnum = 7
        chainText = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = "L-L-L-L-L"
        print("5")
        animTrack5:Play()
    --  p.PlayerGui.MainGui.Frame["Ki Frame"].Size  = p.PlayerGui.MainGui.Frame["Ki Frame"].Size  + UDim2.new(.03, 0, 0, 0)
        wait(0.5)
        chainnum = 9

    else
    if KeyCode == Enum.UserInputType.MouseButton1 and script.canAttack.Value == true and chainnum == 9 then
        chainnum = 10
        chainText = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = "L-L-L-L-L-L"
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.TextColor3 = Color3.new(0, 255, 0)
        print("6")
        animTrack6:Play()
    --  p.PlayerGui.MainGui.Frame["Ki Frame"].Size  = p.PlayerGui.MainGui.Frame["Ki Frame"].Size  + UDim2.new(.03, 0, 0, 0)
        wait(0.5)
        chainnum = 0
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = "None"
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.TextColor3 = Color3.new(255, 255, 0)
        end
    end
    end
    end
    end
    end
end

local oldtext = chainText

while wait(1) do 
    if p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text == oldtext and chainnum > 0 then
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = 'None' --this would technically be none since it's empty
chainnum = 0
    else
        oldtext = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text
    end
end

UIS.InputBegan:Connect(Combat)

The while wait(1) do part is where the problem occurs. Any help?

0
Change the while loop to this: GiveMeYourPudding 64 — 5y
0
while true do GiveMeYourPudding 64 — 5y
0
if p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text == oldtext and chainnum > 0 then 111 p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = 'None' --this would technically be none since it's empty 112 chainnum = 0 113 else 114 oldtext = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text 115 end wait(1) end GiveMeYourPudding 64 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

Change your while loop to this:

while true do
    if p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text == oldtext and chainnum > 0 then
        p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text = 'None' --this would technically be none since it's empty
        chainnum = 0
    else
        oldtext = p.PlayerGui.PlayerGuis.Menu.mouseLabels.TextLabel.Text
    end
    wait(1)
end
0
I tried this, but when I change it to that, and whenever I click the mouse button, nothing happens this time oSyM8V3N 429 — 5y
0
Ohhh, it does work. I just had it in the wrong place. Thanks Firplius for the help, I was stuck on this for a long while :) oSyM8V3N 429 — 5y
Ad

Answer this question