I need help ASAP. I seem to have a bug with the player UI.
Script:
local part = script.parent
local ProximityPrompt = part.ProximityPrompt
local workspace = game.Workspace
local UI = game.Players.LocalPlayer.PlayerGui.ScreenGui.Candy
ProximityPrompt.Triggered:connect(function()
if UI.Text == "1st. Find all the candy (0/20)" then
UI.Text = "1st. Find all the candy (1/20)"
elseif UI.Text == "1st. Find all the candy (1/20)" then
UI.Text = "1st. Find all the candy (2/20)"
elseif UI.Text == "1st. Find all the candy (2/20)" then
UI.Text = "1st. Find all the candy (3/20)"
elseif UI.Text == "1st. Find all the candy (3/20)" then
UI.Text = "1st. Find all the candy (4/20)"
elseif UI.Text == "1st. Find all the candy (4/20)" then
UI.Text = "1st. Find all the candy (5/20)"
elseif UI.Text == "1st. Find all the candy (5/20)" then
UI.Text = "1st. Find all the candy (6/20)"
elseif UI.Text == "1st. Find all the candy (6/20)" then
UI.Text = "1st. Find all the candy (7/20)"
elseif UI.Text == "1st. Find all the candy (7/20)" then
UI.Text = "1st. Find all the candy (8/20)"
elseif UI.Text == "1st. Find all the candy (8/20)" then
UI.Text = "1st. Find all the candy (9/20)"
elseif UI.Text == "1st. Find all the candy (9/20)" then
UI.Text = "1st. Find all the candy (10/20)"
elseif UI.Text == "1st. Find all the candy (10/20)" then
UI.Text = "1st. Find all the candy (11/20)"
elseif UI.Text == "1st. Find all the candy (11/20)" then
UI.Text = "1st. Find all the candy (12/20)"
elseif UI.Text == "1st. Find all the candy (12/20)" then
UI.Text = "1st. Find all the candy (13/20)"
elseif UI.Text == "1st. Find all the candy (13/20)" then
UI.Text = "1st. Find all the candy (14/20)"
elseif UI.Text == "1st. Find all the candy (14/20)" then
UI.Text = "1st. Find all the candy (15/20)"
elseif UI.Text == "1st. Find all the candy (15/20)" then
UI.Text = "1st. Find all the candy (16/20)"
elseif UI.Text == "1st. Find all the candy (16/20)" then
UI.Text = "1st. Find all the candy (17/20)"
elseif UI.Text == "1st. Find all the candy (17/20)" then
UI.Text = "1st. Find all the candy (18/20)"
elseif UI.Text == "1st. Find all the candy (18/20)" then
UI.Text = "1st. Find all the candy (19/20)"
elseif UI.Text == "1st. Find all the candy (19/20)" then
UI.Text = "1st. Find all the candy (20/20)"
end
script.Parent:Destroy()
script.Sound:Play()
wait(1)
script.Parent:Remove()
end)
Error Message:
Attempted to index nil with ‘PlayerGui’ (Line 4).
Anyone know how to fix this?