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)

5 comments

0

Man, local variables man.

0

so do I put the choosepunch outside the function ?

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

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?

0

Use local variables. They are more easily accessible from the script than global ones.