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 local Leaderstat = Player.Stats.Faction local Leaderstat = Player.Stats function choose_faction(name) local Leaderstat = Player.Stats.Faction Leaderstat.Value = name Player.TeamColor = BrickColor.new("Cyan") Player:LoadCharacter() 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)
This script goes with a GUI which are placed in ReplicatedStorage.
it better be a local script and because you said
local Player = game.Players.LocalPlayer
The Player won't load in the actual game... Try doing this...
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 wait(1) -- added wait so it gives amount of time for the player to load local Player = game:GetService("Players").LocalPlayer local Leaderstat = Player.Stats.Faction local Leaderstat = Player.Stats function choose_faction(name) local Leaderstat = Player.Stats.Faction Leaderstat.Value = name Player.TeamColor = BrickColor.new("Cyan") Player:LoadCharacter() 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)
if that won't work using PlayerAdded like this..
game:GetService("Players").PlayerAdded:connect(function(Player) 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 Leaderstat = Player.Stats.Faction local Leaderstat = Player.Stats function choose_faction(name) local Leaderstat = Player.Stats.Faction Leaderstat.Value = name Player.TeamColor = BrickColor.new("Cyan") Player:LoadCharacter() 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) end)