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

Changing Team based on StringValue?

Asked by 6 years ago
local qingyun   = script.Parent.Frame.Qingyun
local tianying  = script.Parent.Frame.Tianying
local thousand  = script.Parent.Frame.Thousand
local longevity = script.Parent.Frame.Longevity
local fenxiang  = script.Parent.Frame.Fenxiang
local ghostking = script.Parent.Frame.Ghost

local Player = game.Players.LocalPlayer

function choose_faction(name)
    local Leaderstat = Player.leaderstats.Faction

    Leaderstat.Value = name

    end
    script.Parent:Destroy()
end

qingyun.MouseButton1Click:connect(function() choose_faction("Qing Yun") end)
tianying.MouseButton1Click:connect(function() choose_faction("Tian Ying") end)  
thousand.MouseButton1Click:connect(function() choose_faction("Thousand Poison") end)  
longevity.MouseButton1Click:connect(function() choose_faction("Longevity") end) 
fenxiang.MouseButton1Click:connect(function() choose_faction("Fen Xiang") end)  
ghostking.MouseButton1Click:connect(function() choose_faction("Ghost King") end)

Hi this is my script for changing class when you click a textbutton, But I am having trouble changing your Team Color based on what button you click.

1 answer

Log in to vote
1
Answered by
luadotorg 194
6 years ago
Edited 6 years ago

Well, the issue here is that you didn't even try changing the team color.

I've scripted for you a small script that will change your team color.

local qingyun   = script.Parent.Frame.Qingyun
local tianying  = script.Parent.Frame.Tianying
local thousand  = script.Parent.Frame.Thousand
local longevity = script.Parent.Frame.Longevity
local fenxiang  = script.Parent.Frame.Fenxiang
local ghostking = script.Parent.Frame.Ghost

local Player = game.Players.LocalPlayer

function choose_faction(name)
     Player:WaitForChild('leaderstats').Faction.Value = name
     Player.TeamColor = game:GetService("Teams"):WaitForChild(name).TeamColor
     script.Parent:Destroy()
end

qingyun.MouseButton1Click:connect(function() choose_faction("Qing Yun") end)
tianying.MouseButton1Click:connect(function() choose_faction("Tian Ying") end)  
thousand.MouseButton1Click:connect(function() choose_faction("Thousand Poison") end)  
longevity.MouseButton1Click:connect(function() choose_faction("Longevity") end) 
fenxiang.MouseButton1Click:connect(function() choose_faction("Fen Xiang") end)  
ghostking.MouseButton1Click:connect(function() choose_faction("Ghost King") end)

Hope this helps you!

0
I got it to works thanks! but now it only works in studio but not in Play Mode Entirely76 2 — 6y
0
@luadotorg, on the local Player variable, also add after the game.Players.LocalPlayer or game.Players.PlayerAdded:Wait() saSlol2436 716 — 6y
Ad

Answer this question