Hello. I am creating team-change gui and i want to do quick respawn. The rest of script is working correctly only player:LoadCharacter() is not working.
local color = "Sand green"
local group = 4384871
local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:Connect(function()
if player:IsInGroup(group) then
player.TeamColor = BrickColor.new(color)
player:LoadCharacter()
script.Parent.Parent.Parent.Visible = false
end
end)

5 comments
You're calling this from a GUI, so I imagine you're trying to do this all locally? You need to handle this all on the server. LoadCharacter, specifically, won't work from the client as well.
so how i can do that with button?
Likely you'll have to use Remotes. https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events
thank you
No problem. If you have issues understanding remotes, feel free to ask in the Site Chat or the Discord. They can be a bit daunting. Good luck.