Hello devforum,
Today’s post is a speed run, my variable (which is being changed inside of a function) isn’t being recognized outside of the function, instead being recognized as the value i defined when I started the script:
THE CODE:
reloading = 0 – what the value is defaulting to, declared script-start
mouse.TargetFilter = workspace
local function activated()
if reloading == true
then
print('sneed')
else
print(reloading) -- prints 0
shootevent:FireServer(mouse.hit.p)
wait(.09)
Text1.Text = workspace:FindFirstChild(tostring(player))['AK-47'].Ammo.Value
end
end
while mousedown == true
do
print("E")
end
local function equipped()
local function reloading(input)
if input.KeyCode == Enum.KeyCode.R
then
reloading = true --what the value SHOULD be
updateAmmo:FireServer()
wait(.09)
Text1.Text = workspace:FindFirstChild(tostring(player))['AK-47'].Ammo.Value
Text2.Text = workspace:FindFirstChild(tostring(player))['AK-47'].AmmoReservoir.Value
print(reloading)
wait(5)
reloading = false
print(reloading) -- the prints inside of this function give out the correct values
end
end