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

How can I kick a player off a seat if they are not on a certain team?

Asked by 5 years ago
Edited 5 years ago

This is what I have currently, in the seat.

seat = script.Parent
teams = game:GetService("Teams")

seat.Changed:Connect(function()
    local occupant = seat.Occupant
    if occupant then
        local character = occupant.Parent
        local player = game.Players:GetPlayerFromCharacter(character)
        if player.TeamColor ~= ("New Yeller") then
            seat.Disabled = true
            seat.Disabled = false
        end
    else

    end
end)

However it gave me this error: Maximum event re-entrancy depth exceeded for Instance.Changed

And this error: While entering function defined in script 'Workspace.Kingseat.Seat.Script', line 4

Edit: I also tried this but it still does not work, however it outputs no error.

seat = script.Parent
teams = game:GetService("Teams")

seat.Touched:Connect(function()
    wait(0.1)
    local occupant = seat.Occupant
    if occupant then
        local character = occupant.Parent
        local player = game.Players:GetPlayerFromCharacter(character)
        if player.TeamColor ~= ("New Yeller") then
            seat.Disabled = true
            seat.Disabled = false
        end
    else

    end
end)
0
TeamColor is not a string. It's a BrickColor. That means that the value you'll have to compare it to must be a BrickColor. Use the BrickColor.new() constructor. DeceptiveCaster 3761 — 5y
0
That still did not help. It outputs no error and doesn't kick me off the seat when on the wrong team. FallenZalio 99 — 5y
0
The seat must not have an occupant then. DeceptiveCaster 3761 — 5y
0
Which code are you referring too, my first or my second? FallenZalio 99 — 5y
View all comments (3 more)
0
Turns out I was just not waiting long enough for it to register if there was as occupant. Thanks for trying to help. FallenZalio 99 — 5y
0
Nevermind it is still not working. It works but only after the first time I sit and then get off FallenZalio 99 — 5y
0
BrickColor I believe can be converted to a string when you input it in tostring() GGRBXLuaGG 417 — 5y

Answer this question