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

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

Asked by 5 years ago

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

0
Format your code!!!! Miniller 562 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

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

Ad

Answer this question