Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

(Roblox Lua) Doesn't seem to make the part CanCollide = true and Transparency = 1?

local Keycarddoor1 = game.Workspace.Keycarddoor1.BrickColor == BrickColor.new("Lime green") local Keycarddoor2 = game.Workspace.Keycarddoor2.BrickColor == BrickColor.new("Lime green") local Keycarddoor3 = game.Workspace.Keycarddoor3.BrickColor == BrickColor.new("Lime green") local Keycarddooropen1 = game.Workspace.Keycarddooropen1.CanCollide == true, game.Workspace.Keycarddooropen1.Transparency == 1 local Keycarddoorscript = Keycarddoor1, Keycarddoor2, Keycarddoor3

if Keycarddoorscript == true then game.Workspace.Keycarddoor1.CanCollide = true, game.Workspace.Keycarddoor1.Transparency == 1 end

1 comment

0

Format your code!!!!

1 answer

✓ Accepted answer

REVISED Server Script

local Keycarddoor1 = workspace.Keycarddoor1
Keycarddoor1.BrickColor = BrickColor.new("Lime green")

local Keycarddoor2 = workspace.Keycarddoor2
Keycarddoor2.BrickColor = BrickColor.new("Lime green")

local Keycarddoor3 = workspace.Keycarddoor3
Keycarddoor3.BrickColor = BrickColor.new("Lime green")

local function Keycarddooropen1()
	workspace.Keycarddooropen1.CanCollide = true
	workspace.Keycarddooropen1.Transparency = 1
end

local Keycarddoorscript = {Keycarddoor1, Keycarddoor2, Keycarddoor3}

if Keycarddoorscript[1] and Keycarddoorscript[2] and Keycarddoorscript[3] then
	Keycarddooropen1()
end

ERRORS

You cannot define a variable in the same line two different ways

local Keycarddoor1 = game.Workspace.Keycarddoor1.BrickColor == BrickColor.new("Lime green")

should be

local Keycarddoor1 = game.Workspace.Keycarddoor1
Keycarddoor1.BrickColor = BrickColor.new("Lime green")

To check if all the values are true, then you need brackets around the table

local Keycarddoorscript = Keycarddoor1, Keycarddoor2, Keycarddoor3

should be

local Keycarddoorscript = {Keycarddoor1, Keycarddoor2, Keycarddoor3}

You cant define the event's actions in a list, but you can use a local function to achieve the same end.

if Keycarddoorscript == true then
	game.Workspace.Keycarddoor1.CanCollide = true, game.Workspace.Keycarddoor1.Transparency == 1
end

should be

if Keycarddoorscript[1] and Keycarddoorscript[2] and Keycarddoorscript[3] then
	Keycarddooropen1()
end

You use the arguments [#] because you are going through table keyvalues

This discussion is preserved as it was. New answers, comments, and votes are closed.