Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a specific group enter a door?

Asked by 9 years ago

Well I wanted team "ct" enter this door. Error says their is no property "Team" in Players. (Ex. Player.Team.TeamColor)

01ctdoor = script.Parent
02 
03function open()
04    ctdoor.CanCollide = false
05    for transparency = 0, 1, .1 do
06        ctdoor.Transparency = transparency
07        wait(.1)
08    end
09end
10 
11function close()
12    for transparency = 1, 0, -.1 do
13        ctdoor.Transparency = transparency
14        wait(.1)
15    end
View all 38 lines...

2 answers

Log in to vote
0
Answered by 9 years ago

Team is indeed, not a valid member or property of Player. But TeamColor is. You'd access it like so:

1player.TeamColor

But you really should use the IsInGroup function.

01group = 1
02 
03script.Parent.Touched:connect(function(hit)
04    if hit.Parent:FindFristChild("Humanoid") then
05        local player = game.Players:GetPlayerFromCharacter(hit.Parent.Humanoid)
06        if player:IsInGroup(group) then
07            --do stuff
08        end
09    end
10end)

Hope this helps. I'm tired, but I want to help all that I can; please forgive any of my incoherence.

0
I don't think "IsInGroup" helps it just does nothing. IsInGroup works for groups connected with roblox and not TeamColor hardhitsniper 30 — 9y
Ad
Log in to vote
0
Answered by
DevArk 50
9 years ago

I like how MINEBLOX106 thinks but here is a better way of doing it.

01local group = 1
02 
03script.Parent.Touched:connect(function(hit)
04    if hit.Parent:FindFirstChild('Humanoid') then
05        if game.Players:FindFirstChild(hit.Parent.Name) then -- make sure its an actual player not a robot
06            if game.Players[hit.Parent.Name]:IsInGroup(group) then
07                open()
08                wait(4)
09                close()
10            end
11        end
12    end
13end)

Answer this question