Ad
Log in to vote
0

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

Asked by 1 month ago
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

Log in to vote
0
Answered by 1 month ago
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

Ad

Answer this question