Gui not working with clicked?

im making something where when you click a textbutton will revert you back to your old avatar after transforming but for some reason its not working at all? i tried running a print statement to see if the code was even running and it didnt print anything. here is my code

local tool = script.Parent
local debounce = false
local oldchar = game.Players.LocalPlayer.Character
local uis = game:GetService("UserInputService")
	local screen ="ScreenGui", game.Players.LocalPlayer.PlayerGui)
	local button ="TextButton", screen)
	button.Position =, 0,0.337, 0)
	button.Size =, 200,0, 50)
	button.Text = "Revert"
	button.TextScaled = true
	button.Visible = true
	button.Active = true
		screen.ResetOnSpawn = false
	local Player = game.Players.LocalPlayer
	local remote = game.ReplicatedStorage.Change



		local playersService = game:GetService("Players")
		local player = game.Players.LocalPlayer

		local humDesc = playersService:GetHumanoidDescriptionFromUserId(player.UserId)

1 Like

Line 3, The character doesn’t load immediately, so you need to wait for the character to load with the CharacterAdded event.

local character = player.CharacterAdded:Wait()
1 Like

thank you i will fix that but do you know how i could fix the gui not working when clicking problem?

Make sure there are no other existing errors in the output box, and if there aren’t any, put a print right after the tool.Activated event to make sure the code in that scope is running.

If the error still occurs, I will investigate more.

the tool activated is working fine and tthere are no errors its just not working.

Using the parent parameter in is deprecated and is likely the issue here. Try parenting the screengui and button in separate lines.