How to get the character because player.Character isn't working

Hey OP, this is a local script right?

The character switch is local if that’s what your asking

I just mentioned it was a local script in the script via comment.

By OP I meant @wrtrewewqwewqwqwqee. I was asking if he put the code in a local script, as the local player property (and UserInputService) don’t work server side.

What should I do to clean it up? it works when you don’t switch characters and I think it’s not that messy

Yes it switches characters using a script

Could you also post the character switch script?

local Jason1 = game.ReplicatedStorage.Jason 
local Player = game.Players.LocalPlayer
local button = script.Parent
local StarterCharacterScripts = game.StarterPlayer.StarterCharacterScripts:GetChildren()
--local CharacterSelector = game.StarterGui["Old Character Slector"].Enabled 
local LocalScripts = {}
local humanoid = Player.Character:WaitForChild("Humanoid")
local walkspeed = humanoid.WalkSpeed 
walkspeed = 0
local rs = game:GetService("ReplicatedStorage") 
local CanContinue = rs:WaitForChild("CanContinueRe")
local GUI = game.StarterGui["Old Character Slector"]

local function onButtonActivated() -- Checking if the player clicked on the block
	local ChosenCharacter = Jason1:Clone()
	local CurrentCharacter = Player.Character or Player.CharacterAdded:Wait()
	local LocalScripts = {}
	--CharacterSelector = false
	for index2,item2 in pairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
		if item2:IsA('LocalScript') then
			item2:Clone().Parent = ChosenCharacter
	CurrentCharacter.Health:Clone().Parent = ChosenCharacter
	ChosenCharacter.Parent = workspace
	ChosenCharacter.Name = Player.Name
	Player.Character = ChosenCharacter
	ChosenCharacter.PrimaryPart.CFrame = CurrentCharacter.PrimaryPart.CFrame
	GUI.Parent = game.Players.LocalPlayer.PlayerGui
	--script.Parent:GetChildren():Isa("Frame").Visible = false
	for index2,item2 in pairs(LocalScripts) do
		item2.Parent = ChosenCharacter


instead of deleting some code i just put - - incase i needed it later

I do local Character = Player.Character or Player.CharacterAdded:Wait() everytime I want to get the character.

Thanks but I don’t know why when I tried that before because I like that method too but it wasn’t working because I switched to a different player character with the script here:

and I don’t know how to get the new player character

Use Character = Player.Character or Player.CharacterAdded:Wait()

to update the character variable.