You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want it to where if my room number tool is collect it well open the door -
What is the issue? Include screenshots / videos if possible!
so I’m trying to script a room door on Roblox but it prints out Room Key does not match the room number! when I have the right room number tool how the system works is it reads the room number from the number value in the too, then that is what allows the door to open but it’s not doing that here my script
local door = script.Parent.CardSystem
local part4 = script.Parent.Part4
local part5 = script.Parent.Part5
local part6 = script.Parent.Part6
local part7 = script.Parent.Part7
local transparencyValue = 1
local originalTransparency = door.Transparency
local originalCanCollide = door.CanCollide
local roomNumber = door:GetAttribute("RoomNumber")
print("Door's Room Number:", roomNumber)
local function revertProperties()
door.Transparency = originalTransparency
part4.Transparency = originalTransparency
part5.Transparency = originalTransparency
part6.Transparency = originalTransparency
part7.Transparency = originalTransparency
door.CanCollide = originalCanCollide
end
local function onTouched(hit)
local character = hit.Parent
if character and hit.Parent then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local backpack = player:FindFirstChild("Backpack")
local tool = backpack:FindFirstChild("Room Key") or character:FindFirstChild("Room Key")
if tool then
local roomKeyValue = tool:FindFirstChild("RoomNumber")
if roomKeyValue then
print("Room Key's Room Number:", roomKeyValue.Value)
end
if roomKeyValue and roomKeyValue.Value == roomNumber then
door.Transparency = transparencyValue
part4.Transparency = transparencyValue
part5.Transparency = transparencyValue
part6.Transparency = transparencyValue
part7.Transparency = transparencyValue
door.CanCollide = false
delay(2, revertProperties)
else
print("Room Key does not match the room number!")
end
else
print("Tool not found!")
end
end
end
end
end
door.Touched:Connect(onTouched)