What do you want to achieve?
So here the idea
I wanna copy and paste (Door) {and it’s need be work}
but here the problem… in code i need copy and paste Script TO!
How can i make just copy and paste Model and it’s gonna be work
What is the issue?
Model–
code
local KeyCardDoor_1 = workspace.World.Levels:FindFirstChild("Accept_Level_1")
local debounce = false
local door1 = KeyCardDoor_1.Door_1
local Scanner = KeyCardDoor_1.Scanner_1
local Card_AcceptLevel1 = {
"Level_1",
"Level_2"
}
-- LOCAL CARD_ACCEPTlevel1 IT'S TOOLS! {Like model Card}
local function DoorAnimation(Part)
Part.CanCollide = false
Part.Transparency = 0.5
debounce = true
wait(2)
Part.CanCollide = true
Part.Transparency = 0
debounce = false
end
local function CheckDoorTest(hit, Type_Accept_Level)
if not debounce then
if not table.find(Type_Accept_Level, hit.Parent.Name) then return print("BOO") end
if table.find(Type_Accept_Level, hit.Parent.Name) then
print("Accept")
end
end
end
--for _, Levels in ipairs(game.Workspace.World.Levels:GetChildren()) do
--if Levels:IsA("Folder") and Levels.Name == "Accept_Level_1" then
-- local Scanner_1 = Levels:FindFirstChild("Scanner_1")
--local Door_1 = Levels:FindFirstChild("Door_1")
-- Scanner_1.Touched:Connect(CheckDoorTest, Accept_Level_1)
--DoorAnimation(Door_1)
--end
--end
-- HERE I TRY MAKE IT WORK
Scanner.Touched:Connect(CheckDoorTest)
What solutions have you tried so far? I try use GetChilder but then i problem with “Accept Level Card” it’s big problem i can’t make 5 types of Accept Level bypass Card key doors
An easy fix is to add a Script in the model, go to the Script’s properties, go to RunContext and pick Client, then paste your original code there. This makes the script work on client while being located under workspace. Then you can simply clone the whole model.
If you want to use 1 script for all doors just loop through all doors and make touched events for their scanners. Do you know how to code? If not, I think ChatGPT can easily do this. I’m not on pc right now so I can’t write.
local KeyCardDoor_1 = workspace.World.Levels:FindFirstChild("Accept_Level_1")
local debounce = false
local door1 = KeyCardDoor_1.Door_1
local Scanner = KeyCardDoor_1.Scanner_1
local Card_AcceptLevel1 = {
"Level_1",
"Level_2"
}
local function DoorAnimation(Part)
Part.CanCollide = false
Part.Transparency = 0.5
debounce = true
wait(2)
Part.CanCollide = true
Part.Transparency = 0
debounce = false
end
local function CheckDoorTest(hit)
if not debounce then
if not table.find(Card_AcceptLevel1, hit.Parent.Name) then return print("BOO") end
if table.find(Card_AcceptLevel1, hit.Parent.Name) then
print("Accept")
end
end
end
for _, Levels in ipairs(game.Workspace.World.Levels:GetChildren()) do
if Levels:IsA("Folder") and Levels.Name == "Accept_Level_1" then
local Scanner_1 = Levels:FindFirstChild("Scanner_1")
local Door_1 = Levels:FindFirstChild("Door_1")
Scanner_1.Touched:Connect(CheckDoorTest)
DoorAnimation(Door_1)
end
end