Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

does anyone know how to fix this error? attempt to index nil with 'Character'?

local options = game.StarterGui.ScreenGui.Options
local Chr = script.Parent.StarterCharacter
local Buttons = {
	options.Kagune,
	options.Magic,
} 

script.Parent.MouseButton1Click:Connect(function(player)
	Chr.Parent = game.StarterPlayer
	local character = player.Character	
	options.BackgroundTransparency = 1
	Buttons.BackgroundTransparency = 1
	Buttons.TextTransparency = 1
	character.Humanoid.Health = 0
	print("done")
end)

1 answer

local options = game.StarterGui.ScreenGui.Options
local Chr = script.Parent.StarterCharacter
local Buttons = {
    options.Kagune,
    options.Magic,
} 

script.Parent.MouseButton1Click:Connect(function(player)
    Chr.Parent = game.StarterPlayer
    local character = player.Character  ~~ Here  
    options.BackgroundTransparency = 1
    Buttons.BackgroundTransparency = 1
    Buttons.TextTransparency = 1
    character.Humanoid.Health = 0
    print("done")
end)

You already got the character which is player, you can just remove Character there so its

local character = player

This discussion is preserved as it was. New answers, comments, and votes are closed.