I'm trying to make it so that when the player clicks z, it changes its appearance to a custom model and clicking z again reverts the player's appearance back to normal. I keep getting "attempt to index nil with 'Clone'" and idk what's wrong:
local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local character = player.Character or player.CharacterAdded:Wait()
local originalModel = character:Clone()
local botModel = workspace:WaitForChild("BOT 2"):Clone()
local isBot = false
UIS.InputBegan:Connect(function(input, _)
if input.KeyCode == Enum.KeyCode.Z then
if isBot then
player.Character = originalModel:Clone() <- This is the line where the error is coming from
else
player.Character = botModel:Clone()
end
character = player.Character
isBot = not isBot
end
end)
