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

How can I make this script Compatible with FE?

Asked by 8 years ago
local Player = game.Players.LocalPlayer
local Teams = game.Lighting.Teams
CurrentGroup = 1020134
-- Colombians

if Player:IsInGroup(CurrentGroup) then
    local Colombians = Teams["Colombians"]
    Colombians.Parent = game.Teams
    Player.TeamColor = BrickColor.new("Bright green")

else

-- Tourist
local Tourist = Teams["Tourist"]
Tourist.Parent = game.Teams
Player.TeamColor = BrickColor.new("Bright yellow")

end 

0
When I did your answer, The teams Disappeared. BadFidelis 5 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

I would use RemoteEvents for client-server communications like this.

Firstly you'd make the serverside code:

local Event = Instance.new("RemoteEvent",game:GetService("ReplicatedStorage")) --Make the event
Event.Name = "MakeTeam" --Give it an obvious name

Event.OnServerEvent:connect(function(Player, TeamName, TeamColor) --Will fire when "Event:FireServer()" is called
    local Team = game:GetService("Lighting")[TeamName]
    Team.TeamColor = TeamColor
    Team.Parent = game:GetService("Teams")
end)

Now for the client-side (your script):

local Player = game.Players.LocalPlayer
local Teams = game.Lighting.Teams
local Event = game:GetService("ReplicatedStorage"):WaitForChild("MakeTeam") --Get our event
CurrentGroup = 1020134
-- Colombians

if Player:GetRankInGroup(CurrentGroup) > 0 then --GetRankInGroup is better as it updates every time you call it

    Event:FireServer("Columbians", BrickColor.new("Bright green")) --Will run the function in the serverscript

else

-- Tourist
    Event:FireServer("Tourist", BrickColor.new("Bright yellow")) --Will run the function in the serverscript

end 
Ad

Answer this question