So I have no errors, I may be doing this script wrong but here. If someone could fix my script r something.
my script is
game.Players.PlayerAdded:Connect(function(Player)
script.Parent.MouseButton1Click:Connect(function()
if Player:GetRankInGroup(5593343) == 254 then
print("Player is corect rank!")
Player.TeamColor = BrickColor.new("Really red")
else print("Player is not correct rank")
Player.TeamColor = BrickColor.new("Dark stone grey")
end
end)
end)
It’s supposed to give the people who are that rank the “Red” rank, but if you aren’t the correct rank then you stay on Choosing team. Here is screen shot of explorer
There are a few issues here. First of all, you’re trying to run a ServerScript from the client. Instead, you will need to use a LocalScript to detect when the button is pressed. Secondly, you can not set a team of a player from the client since it won’t replicate to the server. Instead, you will need to use a RemoteEvent.
So for the LocalScript you should do something like this:
local RemoteEvent = game:GetService("ReplicatedStorage").Event -- A path to your RemoteEvent
script.Parent.MouseButton1Click:Connect(function()
RemoteEvent:FireServer()
end)
And in the ServerScript you would put the rest of your code:
local RemoteEvent = game:GetService("ReplicatedStorage").Event -- A path to your RemoteEvent
RemoteEvent.OnServerEvent:Connect(function(Player)
if Player:GetRankInGroup(5593343) == 254 then
print("Player is corect rank!")
Player.TeamColor = BrickColor.new("Really red")
else
print("Player is not correct rank")
Player.TeamColor = BrickColor.new("Dark stone grey")
end
end)