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

How do you make a team only button door? - Drxift

I feel this will be useful, for my future builds and my current ones, especially. I am intrigued by this idea, and if somebody were to answer I would be ever so grateful. I know how to make a button door, however, I don't know how to limit it to a certain team. I have tried combining button doors and team doors, but I haven't quite made the right transition.

3 comments

0

This place is for helping with your scripts, we don't give you scripts, if you have a problem, something you don't understand, but if you're asking us to do things for you that's against the rules, please learn scripting before starting some stuff.

0

I said in the description that I had already tried a script...

0

then show the script

1 answer

local Part = script.Parent
local TeamRestriction = "Pirates" 

local function onTouch(Hit)
 if Hit.Parent:FindFirstChildWhichIsA("Humanoid") then -- Make sure it is a player
 local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent) -- Use a special method named GetPlayerFromCharacter, which you get a player from the players model in workspace
 if Player.Team == TeamRestriction then -- Check for his team
  -- What to do if the players team matches "Pirate"
 end
 end
end

Part.Touched:Connect(onTouch) — Assign connect function to onTouch

i did this on phone, so some symbols may be wrong; this is to show use of GetPlayerFromCharacter, if your not looking for this, there’s a extra parameter to the MouseClick event from the ClickDetector object, the 1st parameter is what player pressed it, for example: ClickDetector.MouseClick:Connect(function(Player) end)

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