Alright so I’m basically making a game like Color block and for my round, I have a table containing all my colors, the server picks one radomly and then sets all pats that are not that color in the table to 0 transparency and it sets CanCollide to false
However it does not seem to be working I’ve spent some time debugging it has nothing do with my bindable event that I have set up.
local ColorBind = game.ReplicatedStorage.ColorBind
local Colors = game.Workspace.Colors
ColorBind.Event:Connect(function()
local ColorTable = Colors:GetChildren()
local Picked = math.random(1, #ColorTable)
local ChosenColor = ColorTable[Picked]
print("Chosen Color is " .. ChosenColor.Name)
print(ChosenColor.BrickColor)
for _, v in pairs(ColorTable) do
if v ~= ChosenColor then
print("Work")
local Trans = v:GetAttribute("Transparency")
Trans = 0
v:SetAttribute("Transparency", Trans)
local CanCollide = v:GetAttribute("CanCollide")
CanCollide = 0
v:SetAttribute("CanCollide", CanCollide)
end
end
end)
wdym by comparing an object for a number? I’m a bit new to scripting so I’m still making some logical mistakes. Could you explain what you mean?
Also I should carify what the if statement is checking, basically it selects a random part that has a certain color my idea was for my if statment to loop through the table and check whether a part is the picked part or if it is the same color as the picked part.
Basically objects are instances and instances are object. An object is something that uses instance.new or anything found in the explorer.
Comparing a number to and object isnt possible because for example
you cant compare a pen and a pencil sharpener because both are different from apart. Another explaination
“this is a string” > 9
that text above isnt possible because you are comparing text(in our case its an instance) next to a number
There is various ways to achieve that but i dont really know what “ColorTable” so i dont know what you are trying to achieve. But like is said
Try replacing the two “v” to an “i” and see if that achieves your goal