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

Changing a players team doesnt work?

Asked by 5 years ago
Edited 5 years ago

I tried this

player = game.Players.LocalPlayer
script.Parent.mousebutton1click:connect(function()
player.Brickcolor = "Dark blue"
end)

Its inside a local script.

[OUTPUT] Brickcolor doesnt belong to player. (There is something wrong with line 3)

0
if your trying to change the team use TeamColor ForeverBrown 356 — 5y

4 answers

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

If you're trying to change the team of a player, I do not recommend doing this on a LocalScript, otherwise do it on a Script so it updates on the server, and for every other player. Remember, LocalScripts only replicate to the Client (you).

What we need to do is use a RemoteEvent, so that way, we can send a request to the server, and the server will carry out a task; for example, changing the team of a player.

-- Local Script
local Players = game:GetService("Players")
local Player = Players.LocalPlayer -- Get the LocalPlayer

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("TeamEvent") -- Find the Remote

script.Parent.MouseButton1Click:Connect(function() -- When the button is clicked
    RemoteEvent:FireServer(BrickColor.new("TeamColor") -- Fire the server
end)

-- Server Script
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvent = Instance.new("RemoteEvent") -- Create Remote
RemoteEvent.Name = "TeamEvent" -- Set its name
RemoteEvent.Parent = ReplicatedStorage -- Set its parent

RemoteEvent.OnServerEvent:Connect(function(plr, TeamColor) -- Listen for events
    plr.TeamColor = TeamColor -- Set the Team Color
end)

So remember, we can only send data that exists both on the server and the client. If we don't, the server will not be able to interpret the data. Since we are sending a BrickColor, we don't need to worry about that.

If you have any questions, feel free to ask me. Sherms#0001

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Player doesn't have a color property, I'm assuming you are referring to the character, which is the physical appearance of the player, or maybe you are referring to TeamColor, which determines which team the player is associated with. What is your objective? I'll edit this answer once you explain it.

0
I want to change their brick color. RebornedSnoop 175 — 5y
Log in to vote
0
Answered by 5 years ago
player = game.Players.LocalPlayer
script.Parent.mousebutton1click:connect(function()
Player.TeamColor = BrickColor.new("Dark blue")
end)

You are trying to change to change brickcolor of player which doesnt make any sense, you need to change teamcolor of player which take a brickcolor value

0
This Will Work But The Only Problem Is That He Said It Was Inside A Local Script And That Means You Are Fixing His Local Script And That You Had A LocalPlayer Varible And That Makes It Change The Team Localy (Mening Only The Local PLayer Will See It And Not Others) ew_001 58 — 5y
Log in to vote
0
Answered by
ew_001 58
5 years ago
Edited 5 years ago

You're Script Doesent Work Becuase First Its Inside A Local Script And Second A Player Doesnt Have A Property Named "Brickcolor" (I think You Ment "TeamColor")

Heres how you can fix it

-- Server Script | Parent: ServerScriptService | Usage: Controls The Team Change Remote

local Remote = Instance.new("RemoteEvent")
Remote.Parent = game:GetService("ReplicatedStorage")
Remote.Name = "TeamRemote"

Remote.OnServerEvent:Connect(function(Player,TeamName)
    local Team = game:GetService("Teams"):FindFirstChild(TeamName")
    if Team then
        Player.Team = Team
    end
end)

-- Local Script | Parent: Inside The Button You Use | Usage: Fires The Team Change Remote

local Remote = Game:GetService("ReplicatedStorage"):WaitForChild("TeamRemote")

local TeamName = "" -- You're Team Name Here

Script.Parent.MouseButton1Click:Connect(function()
    Remote:FireServer(TeamName)
end)

Also Heres How You Can Add A Team (You Can Just Copy And Paste These Lines And Rename Them To Add More)

-- Server Script | Parent: ServerScriptService | Usage: Adds Teams

local Teams = game:GetService("Teams")

local DarkBlue = Instance.new("Team")
DarkBlue.Parent = Teams
DarkBlue.Name = "Darkblue" -- Team Name
DarkBlue.TeamColor = "Darkblue" -- Team Color

I Hope This Helps You And Works :D

Answer this question