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

how to make it true if one of the button is pressed?

Asked by 5 years ago
Edited 5 years ago

how can i make that Criminal true if the criminal button is clicked?

local Target = {["Criminal"] = false, ["Police"] = false}
Criminal.MouseButton1Click:connect(function()
Target = {["Criminal"] = true]
end)
Police.MouseButton1Click:connect(function()
Target = {["Police"] = true]
end)
wait(1)
for i,v in pairs(game.Workspace:GetChildren()) do
if Target[v.Name] then
print(v.Parent)
end
end

this doesn't seem to work when i try to activate both, as it only prints the other 1

1 answer

Log in to vote
0
Answered by 5 years ago

Do it like this,

local Target = {["Criminal"] = false, ["Police"] = false}

print(Target.Criminal) -- prints false
Target.Criminal = true -- < < this
print(Target.Criminal) -- prints true

Don't do it like Target = {["Criminal"] = true ] or it will return a syntax being incorrect. And reminder, you cannot have two (2) '=' in a same line.

0
Thanks it worked. Kallisus 43 — 5y
0
yw ;D glad i could help NickAtNick 163 — 5y
Ad

Answer this question