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

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

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.

01-- Local Script
02local Players = game:GetService("Players")
03local Player = Players.LocalPlayer -- Get the LocalPlayer
04 
05local ReplicatedStorage = game:GetService("ReplicatedStorage")
06local RemoteEvent = ReplicatedStorage:WaitForChild("TeamEvent") -- Find the Remote
07 
08script.Parent.MouseButton1Click:Connect(function() -- When the button is clicked
09    RemoteEvent:FireServer(BrickColor.new("TeamColor") -- Fire the server
10end)
11 
12-- Server Script
13local Players = game:GetService("Players")
14local ReplicatedStorage = game:GetService("ReplicatedStorage")
15 
View all 22 lines...

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
1player = game.Players.LocalPlayer
2script.Parent.mousebutton1click:connect(function()
3Player.TeamColor = BrickColor.new("Dark blue")
4end)

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

01-- Server Script | Parent: ServerScriptService | Usage: Controls The Team Change Remote
02 
03local Remote = Instance.new("RemoteEvent")
04Remote.Parent = game:GetService("ReplicatedStorage")
05Remote.Name = "TeamRemote"
06 
07Remote.OnServerEvent:Connect(function(Player,TeamName)
08    local Team = game:GetService("Teams"):FindFirstChild(TeamName")
09    if Team then
10        Player.Team = Team
11    end
12end)
13 
14-- Local Script | Parent: Inside The Button You Use | Usage: Fires The Team Change Remote
15 
View all 22 lines...

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

1-- Server Script | Parent: ServerScriptService | Usage: Adds Teams
2 
3local Teams = game:GetService("Teams")
4 
5local DarkBlue = Instance.new("Team")
6DarkBlue.Parent = Teams
7DarkBlue.Name = "Darkblue" -- Team Name
8DarkBlue.TeamColor = "Darkblue" -- Team Color

I Hope This Helps You And Works :D

Answer this question