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

Script that is supposed to pick a random image not working, why?

Asked by 6 years ago

My script is supposed to make the random image visible and the other not visible for a certain amount of time. For some reason it isn't working and I cant seem to find out why.

Here is the script

plr = script.Parent.Parent.Parent.Parent.Parent
income = script.Parent.income

--1053468311 -- hitleft
--1053474997 -- hitright


script.Parent.MouseButton1Click:connect(function()
    plr.leaderstats.Hits.Value = plr.leaderstats.Hits.Value + income.Value
    choosepunch = math.random(1,2)
    if choosepunch==1 then
            game.StarterGui.ScreenGui.HitRight.Visible= false
            game.StarterGui.ScreenGui.ImageLabel.Visible= false
            wait(10)
            game.StarterGui.ScreenGui.HitRight.Visible= true
            game.StarterGui.ScreenGui.ImageLabel.Visible= true
            wait(10)
        else if choosepunch== 2 then
            game.StarterGui.ScreenGui.HitLeft.Visible= false
            game.StarterGui.ScreenGui.ImageLabel.Visible= false
            wait(5)
            game.StarterGui.ScreenGui.HitLeft.Visible= true
            game.StarterGui.ScreenGui.ImageLabel.Visible= true
            wait(5)
        end
    end
end)
0
Man, local variables man. hiimgoodpack 2009 — 6y
0
so do I put the choosepunch outside the function ? 1Messi3903 -5 — 6y
0
Why do people use an if statment if there is a certain number, use tables please, plus in ROBLOX LUA, its elseif (yes they are together) not else if saSlol2436 716 — 6y
0
When you say it's not working, what do you mean? Do you get errors? If so, what are they. Or do you mean nothing happens? or do you mean that choosepunch==1 always happens? Brouhahaha 27 — 6y
0
Use local variables. They are more easily accessible from the script than global ones. hiimgoodpack 2009 — 6y

Answer this question