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

Scanning door w/ pad script?

So basically I need to make a door with a pad and what I need it to do is when a player stands on the pad it scans them and if they are the right team it opens but if they aren't it just says error, eg. this is a police door so a police man stands on the little scanning pad then the door opens because its a police door, but if a criminal or another type of leaderboard name stands on it, it says error, so yeah I basically need a scan pad and a door script if that is possible, :)

1 comment

0

Don't ask for scripts, ask for help.

1 answer

First of all what I suggest to do is a String table which contains all of the teams, I would define it like this: teams = { "Police", "Criminal", "Civilian", "Alien" } After this I need to do a function that get called every second, this function checks the player's team:

local players = game.Players:GetChildren()
local playerteam
teams = {"Police", "Criminal", "Civilian", "Alien"}
function onUpdate()
	for _, player in pairs(players) do
		local team = player:FindFirstChild("Team")
		for _, t in pairs(teams) do
			if team.Value == t.Value then
				playerteam = t.Value
			end
		end
	end
	wait(1)
	onUpdate()
end

After this I can finally make the door script, so add this down:

function onDoorTouched(part)
	if part.Parent.Name == playerteam then
		part.Transparency = 0.5
		part.CanCollide = false
	else
		// error code here
	end
end

Now we need to call this function on EVERY door of the game, so I suggest you to do something like this: game.Workspace.Doors.TEAM.door1/door2/door3/etc. Examples:

--Civilian's doors
game.Workspace.Doors.Civilian.door1
game.Workspace.Doors.Civilian.door2
game.Workspace.Doors.Civilian.door7
[...]
--Police's doors
game.Workspace.Doors.Police.door5
[...]

WARNING: name the team's models AS SAME AS the teams in the array (the table "teams") After this we need to make the script =) Put this under everything, it isn't a function!! Just put it under everything!

for _, team in pairs (teams) do
	for _, door in pairs (team:GetChildren()) do
		local path = game.Workspace
		local door_path = team.door
		door_path.Touched:Connect(onDoorTouched)
	end
end

That's ONLY the door code, since I'm hurrying I can't now explain you how to do the Scan Pad script, sorry! Ps: the script may gives problems/crashes, write me in a PM the stacktrace (the errors in the output).

PPs: Remember to define a StringValue into the player! Name it "Team"!

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