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

screen gui dosent show up on screen how do i fix this?

hello again! i made a pizza with a click detector when you click it its supposed to show a gui but it dosent show anything and all i see in the output is the print messages

script:

script.Parent.ClickDetector.MouseClick:Connect(function()
	script.Parent.Parent.SoundEmmiter.YumYum:Play()
	print("Somebody ate Altera's pizza!")
	wait(3)
	print("NOW THEY WILL PAY FOR IT")
	game.StarterGui.PizzaGui.Enabled = true
	wait(1)
	game.StarterGui.PizzaGui.PizzaMessage.Text = "Mhmm.. This pizza tastes good!"
	wait(4)
	game.StarterGui.PizzaGui.PizzaMessage.Text = "Uhm.. why do i hear boss music?"
	
	game.StarterGui.PizzaGui.Enabled = false
	wait(4)
	game.StarterGui.DiedScreen.Enabled = true
	game.StarterGui.DiedScreen.Front.DeadMessage.Text = "YOU DIED"
	wait(3)
	game.StarterGui.DiedScreen.Front.DeadMessage.Text = "you should have not ate that pizza.."
end)

btw im a beginner scripter :D

1 comment

3 answers

✓ Accepted answer

Hello! :D

Your problem here is that you are using StarterGui instead of PlayerGui. StarterGui is the Gui that you edited in ROBLOX studio. However, when the game starts up, the GUI's in StarterGui get cloned into each player's PlayerGui. Therefore, anything you script must be done so from the PlayerGui (If that didn't make sense, I'd be happy to try to explain it in a different way)

What you need to do is to detect which player clicked the pizza, so you would start your script off with this:

script.Parent.ClickDetector.MouseClick:Connect(function(plr)

Then you need to change all of your "game.StarterGui" to "plr.PlayerGui"

Here's would be the solution to the first part of your script - if you can't figure out the rest I'm happy to help

script.Parent.ClickDetector.MouseClick:Connect(function() --This line has been edited
	script.Parent.Parent.SoundEmmiter.YumYum:Play()
	print("Somebody ate Altera's pizza!")
	wait(3)
	print("NOW THEY WILL PAY FOR IT")
	plr.PlayerGui.PizzaGui.Enabled = true --This line has been edited
	wait(1)
	plr.PlayerGui.PizzaGui.PizzaMessage.Text = "Mhmm.. This pizza tastes good!" --This line has been edited

I hope this helps! If you have any questions, please ask :)

2 comments

0

thanks! it works fine now

0

That's great! Good luck with your future scripts :)

Hey! Use 'game.StarterGui.PizzaGui.Visible = true' Instead. I hope i was able to help!

2 comments

0

it says 'Visible is not a valid member of ScreenGui "StarterGui.PizzaGui"

0

Everything else seems proper. sorry for taking your time

To fix the screen gui, you would have to use PlayerGui which is located in game.Players.

script.Parent.ClickDetector.MouseClick:Connect(function(Click)
	local Player = game.Players:GetPlayerFromCharacter(Click) --gets the player
	script.Parent.Parent.SoundEmmiter.YumYum:Play()
	print("Somebody ate Altera's pizza!")
	wait(3)
	print("NOW THEY WILL PAY FOR IT")
	Player.PlayerGui.PizzaGui.Enabled = true
	wait(1)
	Player.PlayerGui.PizzaGui.PizzaMessage.Text = "Mhmm.. This pizza tastes good!"
	wait(4)
	Player.PlayerGui.PizzaGui.PizzaMessage.Text = "Uhm.. why do i hear boss music?"

	Player.PlayerGui.PizzaGui.Enabled = false
	wait(4)
	Player.PlayerGui.DiedScreen.Enabled = true
	Player.PlayerGui.DiedScreen.Front.DeadMessage.Text = "YOU DIED"
	wait(3)
	Player.PlayerGui.DiedScreen.Front.DeadMessage.Text = "you should have not ate that pizza.."
end)

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