New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 11 days ago
Edited 11 days 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. BashCaster 2371 — 11d
0
That still did not help. It outputs no error and doesn't kick me off the seat when on the wrong team. FallenZalio 33 — 11d
0
The seat must not have an occupant then. BashCaster 2371 — 11d
0
Which code are you referring too, my first or my second? FallenZalio 33 — 11d
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 33 — 11d
0
Nevermind it is still not working. It works but only after the first time I sit and then get off FallenZalio 33 — 11d
0
BrickColor I believe can be converted to a string when you input it in tostring() GGRBXLuaGG 332 — 11d

Answer this question