Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Changing Team based on StringValue?

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

✓ Accepted answer

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!

2 comments

0

I got it to works thanks! but now it only works in studio but not in Play Mode

0

@luadotorg, on the local Player variable, also add after the game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()

This discussion is preserved as it was. New answers, comments, and votes are closed.