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

Detail garage team door. Where is it/I going wrong?

Asked by 5 years ago
Edited 5 years ago

Line 6 is where I thought it will work but it's not. If you remove player.TeamColor == BrickColor.new("Institutional white") and then it works, but I am trying to make a team door. It's a multiple part garage door. Half was solved already (Garage door part) but the team door part wasn't solved.

local MainPart = script.Parent
local Model = MainPart.Parent.Door
player = game.Players

function toggleVisibility(bool)
    if  player.TeamColor == BrickColor.new("Institutional white") and bool == false then
        for i,v in pairs(Model:GetChildren()) do
            v.Transparency = 1
            v.CanCollide = false
        end
    wait (2)
        for i,v in pairs(Model:GetChildren()) do
            v.Transparency = 0
            v.CanCollide = true
            script.Parent.Parent.Door.Part7.Transparency = 0.4
        end
    end
end

function onTouched(touched)
    toggleVisibility(false)
    wait(2)
    toggleVisiblilty(true)
end

MainPart.Touched:Connect(onTouched)
0
game.Players is a service. 'player' (game.Players) is not a player, but a service.. so saying 'player.TeamColor' makes no sense because TeamColor is not a valid member of game.Players. pidgey 548 — 5y
0
True, AlertShamrock 37 — 5y

1 answer

Log in to vote
1
Answered by
Torren_Mr 334 Moderation Voter
5 years ago
Edited 5 years ago

You put player as game.Players which is a list of players, you need to specify a player. You will need to get the player who touched, below there will be a script that will do that.

local MainPart = script.Parent
local Model = MainPart.Parent.Door

function toggleVisibility(bool, touched)
    local player = game.Players:GetPlayerFromCharacter(touched.Parent) --Gets player from character, touched.Parent is the player character.
    if  player.TeamColor == BrickColor.new("Institutional white") and bool == false then
        for i,v in pairs(Model:GetChildren()) do
            v.Transparency = 1
            v.CanCollide = false
        end
    wait (2)
        for i,v in pairs(Model:GetChildren()) do
            v.Transparency = 0
            v.CanCollide = true
            script.Parent.Parent.Door.Part7.Transparency = 0.4
        end
    end
end

function onTouched(touched) --Touched is the part that touched the door.
    if touched.Parent:FindFirstChild("Humanoid") then --Checks if the touched part is a player.
        toggleVisibility(false, touched)
        wait(2)
        toggleVisiblilty(true, touched)
    end
end

MainPart.Touched:Connect(onTouched)

Replace your script with the one above, this should work. Comment if you have any questions or if it doesn't work.

Ad

Answer this question