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

Door script not functioning at all, no errors?

I tried making a proximity prompt keycard door using this tutorial https://devforum.roblox.com/t/introduction-to-tweening-models/315253 but nothing is happening, no prints or errors. Here's the script:

local Players = game:GetService("Players")
local ProximityPromptService = game:GetService("ProximityPromptService")
local TweenService = game:GetService("TweenService")

local reader1 = script.Parent.Scanner1
local reader2 = script.Parent.Scanner1

local sounds = script.Parent.Sounds

local door1 = script.Parent.Door1
local door2 = script.Parent.Door2

local door1root = door1.RootPart
local door2root = door2.RootPart

local prompt1 = reader1.CardScanner.Attachment.ProximityPrompt
local prompt2 = reader2.CardScanner.Attachment.ProximityPrompt

local door1tweeninfo = TweenInfo.new()
local door1tween = TweenService:Create(door1root, door1tweeninfo, {
	CFrame = door1root.CFrame * CFrame.new(door1root.Size.X + 0.1, 0, 0)
})

local function FindTool(player)
	return player.Backpack:FindFirstChild("SD") or player.Character:FindFirstChild("SD") or player.Backpack:FindFirstChild("L4") or player.Character:FindFirstChild("L4") or player.Backpack:FindFirstChild("L5") or player.Character:FindFirstChild("L5") or player.Backpack:FindFirstChild("Omni") or player.Character:FindFirstChild("Omni") or player.Backpack:FindFirstChild("MTF") or player.Character:FindFirstChild("MTF")
end

local function promptTriggered(player)
	print("TRIGGERED")
	local Tool = FindTool(player)
	if Tool then
		print("Opened!")
		reader1.LightAccept.Material = Enum.Material.Neon
		reader2.LightAccept.Material = Enum.Material.Neon
		prompt1.Enabled = false
		prompt2.Enabled = false
		door1tween:Play()
		reader1.LightAccept.Material = Enum.Material.Glass
		reader2.LightAccept.Material = Enum.Material.Glass
		prompt1.Enabled = true
		prompt2.Enabled = true
	else
		print("Declined!")
		sounds.Decline:Play()
		reader1.LightDecline.Material = Enum.Material.Neon
		reader2.LightDecline.Material = Enum.Material.Neon
		prompt1.Enabled = false
		prompt2.Enabled = false
		task.wait(0.5)
		reader1.LightDecline.Material = Enum.Material.Glass
		reader2.LightDecline.Material = Enum.Material.Glass
		prompt1.Enabled = true
		prompt2.Enabled = true
	end
end

prompt1.Triggered:Connect(promptTriggered)
prompt2.Triggered:Connect(promptTriggered)

1 answer

Try using tables:

local Cards = {
	"SD";
	"L4";
	"L5";
	"Omni";
	"MTF";
}

local function FindTool(player)
	local character = player.Character
	if character:FindFirstChildOfClass("Tool") then -- Checks if the player has a tool equipped.
		local Tool = character:FindFirstChildOfClass("Tool")

		if table.find(Cards, Tool.Name) then
			return Tool
		else
			return nil
		end
	end
end

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