I am very new to Roblox coding, so i’m not very sure what i’m doing. In my script, I want the function leftClick to only run when muturn = true. But whenever I click a button that runs this script it always runs function leftClick even though it should only run when muturn is true. At the end of the script, I set muturn to false.
I want the function leftClick to only run when muturn is true.
local module = require(game.ReplicatedStorage.ModuleScript)
local damagem = require(game.ReplicatedStorage.DamageTaken)
local me = script.Parent
local p = 30
local b = 1
local opHealth = game.StarterGui.ScreenGui.TextButton.MoveScript.CharmanderHealth
opHealth.Value = module.ch
local muturn = true
if muturn == true then
local function leftClick()
print("calculating damage")
damagem = ((((2*5/5+2)*module.sa*p/module.cd)/50)+2)*b*10/10*234/255
damagem = damagem+0.5
damagem = math.floor(damagem)
print(damagem)
module.ch = module.ch - damagem
print(module.ch)
wait(1)
opHealth.Value = module.ch
muturn = false
print(false)
end
me.MouseButton1Click:Connect(leftClick)
end
if muturn == false then
print("not my turn")
local function nm()
print("no")
end
me.MouseButton1Click:Connect(nm)
end
thank you