in all three of these functions i call out to the player gui, but for some reason the script allows me to index through LocalPlayer in the first function but not the second or third function. Can anyone tell me why, and how to make this work?
ClickEvent.MouseClick:connect(function()
game.Players.LocalPlayer.PlayerGui.AddToCartPrompt.Prompt.Visible = true
end)
-- this one above works perfectly fine, however the script below doesn't.
game.Players.LocalPlayer.PlayerGui.AddToCartPrompt.Prompt.YesButton.MouseButton1Click:connect(function()
game.Players.LocalPlayer.PlayerGui.AddToCartPrompt.Prompt.Visible = false
game.Players.LocalPlayer.PlayerGui.Cart.CartBox.Visible = true
end)
game.Players.LocalPlayer.PlayerGui.AddToCartPrompt.Prompt.NoButton.MouseButton1Click:connect(function()
game.Players.LocalPlayer.PlayerGui.AddToCartPrompt.Prompt.Visible = false
end)

2 comments
Try using "game:GetService("Players").LocalPlayer" instead of "game.Players.LocalPlayer". It usually fixes the problem.
Set a variable to LocalPlayer so you don't have to retry.