So I am trying to make a dropper that when purchased uses a bool to tell my dropper to give mere money, here is my code
function onClicked(playerWhoClicked)
if Mybool then --The Mybool in this phrase has an error stating that Mybool is a unknown global
script.Parent.BrickColor = BrickColor.Red()
local points = playerWhoClicked.leaderstats.Copper
points.Value = points.Value-1
local debrisServ = game:GetService('Debris')
local blockLife = 1
local dropper = Instance.new('Part', game.Workspace)
dropper.Anchored = false
dropper.CFrame = CFrame.new(-133, 9, 93)
local dropPart = Instance.new('Part')
dropPart.Color = Color3.new(0,0,0)
wait(1.2)
local points = playerWhoClicked.leaderstats.Money
points.Value = points.Value+7
wait(4)
script.Parent.BrickColor = BrickColor.Green()
else
script.Parent.BrickColor = BrickColor.Red()
local points = playerWhoClicked.leaderstats.Copper
points.Value = points.Value-1
local debrisServ = game:GetService('Debris')
local blockLife = 1
local dropper = Instance.new('Part', game.Workspace)
dropper.Anchored = false
dropper.CFrame = CFrame.new(-133, 9, 93)
local dropPart = Instance.new('Part')
dropPart.Color = Color3.new(0,0,0)
wait(1.2)
local points = playerWhoClicked.leaderstats.Money
points.Value = points.Value+5
wait(4)
script.Parent.BrickColor = BrickColor.Green()
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
That was the dropper this is the upgrader
Mybool = false
function onClicked(playerWhoClicked)
Mybool = true --This should technically make Mybool a global but it does not
game.Workspace.B1.Transparency =100
game.Workspace.PA.Transparency =0
game.Workspace.PB.Transparency =0
game.Workspace.PD.Transparency =0
game.Workspace.PE.Transparency =0
local points = playerWhoClicked.leaderstats.Money
points.Value = points.Value-20
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
This all works fine, but my droppers value of cash for the ore will not change, sorry if my last question seems similar but I cannot find a way around it.

7 comments
Which function do you recommend I use I have tried a few that I thought were correct and came up with the same error
Oh, duh. You can also use _G which makes an ACTUAL global variable. You'd have to figure out how to verify which player you are referencing though.
So I would say: Mybool = true_G???
No, sorry for not being clear. It's _G.MyBool = true. As FrostTaco state.
Thedestroyer, please read my answer and it tells you.
THANKS SO MUCH! that question was on my nerves for SOOOOOO long and you solverd it with the _G. thing thanksss!
Thedestroyer, you don't have to change it, but I'm just saying I was the original one to post the _G, and I kinda like my reputation. xD Again, if you don't want to, then don't change it :P