I'm trying to script a badge that awards the player when they typed the correct password, but it keeps showing up with the 'attempt to index nil with 'UserId' ' error. How can I fix this?
I used a local script in a surface gui:
script.Parent.MouseButton1Click:Connect(function()
if script.Parent.Parent.TextBox.Text == "krxtenaa" then
script.Parent.Parent.Parent.Desktop.Visible = true
script.Parent.Parent.TextBox.Text = ""
local BadgeService = game:GetService("BadgeService")
BadgeService:AwardBadge(player.UserId, 2124658487)
elseif script.Parent.Parent.TextBox.Text == "26/4/2019" then
script.Parent.Parent.Parent.VoiceMemo.TextButton.Visible = true
script.Parent.TextScaled = true
script.Parent.Text = "Secret Voice Memo Unlocked."
wait(2)
script.Parent.TextScaled = false
script.Parent.Text = "Enter"
script.Parent.Parent.TextBox.Text = ""
else script.Parent.Text = "Incorrect!"
wait(2)
script.Parent.Text = "Enter"
script.Parent.Parent.TextBox.Text = ""
end
end)