When I reset/load my character the text button stop working

I will show some code, but I don't think it will help much

The menu code(ik its messy)

local LocalPlayer = game:GetService("Players").LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChoosingTeamPanel = PlayerGui:WaitForChild("ChoosingTeamPanel")
local HostPanel = PlayerGui:WaitForChild("HostPanel")
local MapShow = PlayerGui:WaitForChild("MapShow")
local Menu = ChoosingTeamPanel:WaitForChild("Menu")
local TeamChoosingGui = ChoosingTeamPanel:WaitForChild("TeamChoosingGui")
local RoundedBobrder  = MapShow:WaitForChild("RoundedBorder")
local ScrollingFrame2 = RoundedBobrder:WaitForChild("ScrollingFrame")
local ExitButton = TeamChoosingGui:WaitForChild("ExitButton")
local ExitButton2 = RoundedBobrder:WaitForChild("ExitButton2")
local ScrollingFrame = HostPanel:WaitForChild("ScrollingFrame")
--ShowTeam and Exit Buttons
ExitButton.MouseButton1Up:Connect(function()
	if ScrollingFrame.Visible == true then
		ScrollingFrame.Visible = not ScrollingFrame.Visible
	end
	TeamChoosingGui.Visible = not TeamChoosingGui.Visible
	RoundedBobrder.Visible = not RoundedBobrder.Visible
end)

ExitButton2.MouseButton1Up:Connect(function()
	if ScrollingFrame.Visible == true then
		ScrollingFrame.Visible = not ScrollingFrame.Visible
	end
	TeamChoosingGui.Visible = not TeamChoosingGui.Visible
	RoundedBobrder.Visible = not RoundedBobrder.Visible
end)

Menu.MouseButton1Up:Connect(function()
	if ScrollingFrame.Visible == true then
		ScrollingFrame.Visible = not ScrollingFrame.Visible
	end
	TeamChoosingGui.Visible = not TeamChoosingGui.Visibl
	RoundedBobrder.Visible = not RoundedBobrder.Visible
end)

Here is one of the buttons scripts

local LocalPlayer = game:GetService("Players").LocalPlayer
local Charater1 = LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local TeamService = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local ChoosingTeamPanel = PlayerGui:WaitForChild("ChoosingTeamPanel")
local HostPanel = PlayerGui:WaitForChild("HostPanel")
local MapShow = PlayerGui:WaitForChild("MapShow")
local Menu = ChoosingTeamPanel:WaitForChild("Menu")
local TeamChoosingGui = ChoosingTeamPanel:WaitForChild("TeamChoosingGui")
local RoundedBobrder  = MapShow:WaitForChild("RoundedBorder")
local ScrollingFrame2 = RoundedBobrder:WaitForChild("ScrollingFrame")
local ScrollingFrame = HostPanel:WaitForChild("ScrollingFrame")
local ExitButton = TeamChoosingGui:WaitForChild("ExitButton")
local ExitButton2 = RoundedBobrder:WaitForChild("ExitButton2")
local Teams = {
	TeamService:FindFirstChild("Host"), --1
	TeamService:FindFirstChild("Auditioner"), --2
	TeamService:FindFirstChild("Judge") --3
}
local ChangeTeamEvent = ReplicatedStorage:WaitForChild("ChangeTeam")
local Teleport = ReplicatedStorage:WaitForChild("Teleport")
local pos1 = Charater1.Position

script.Parent.MouseButton1Up:Connect(function()
	ChangeTeamEvent:FireServer(Teams[2])
end)

Here's the remote event

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ChangeTeamEvent = ReplicatedStorage:WaitForChild("ChangeTeam")

ChangeTeamEvent.OnServerEvent:Connect(function(plr, Team2)
	plr:LoadCharacter()
	plr.Team = Team2
end)

ChangeTeamEvent.OnServerEvent:Connect(function(plr, Team3)
	plr:LoadCharacter()
	plr.Team = Team3
end)

ChangeTeamEvent.OnServerEvent:Connect(function(plr, Team1)
	plr:LoadCharacter()
	plr.Team = Team1
end)

Thank you!

1 comment

0

So sorry for messy code