Problem with team changer

I made a script for the player to enter a team, but I get it by name in the text, but it gives me an error. Below:

Unable to assign property Team. Object expected, got string 
game.ReplicatedStorage.ServerControllers.Job.OnServerEvent:Connect(function(p,team)
    if team then
    p.Team = team
    p:LoadCharacter()
local teamChange = game.ReplicatedStorage.ServerControllers.Job

for i,v in pairs(mainjobs:GetChildren()) do
    if v:IsA("Frame") then
        warn("---")
        v.Button.MouseButton1Click:Connect(function()
            teamChange:FireServer(v.Title.Text)
        end)
    end
end

Is this a local script? or a server script?

It is a local script. It doesn’t server script

You don’t assign the team as a string, you assign it as a team object. You would need to do:

player.Team = game:GetService("Teams")[team]
--or
player.Team = game:GetService("Teams"):FindFirstChild(team)

where player is the player and team is the team name.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.