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

How do I make things happen in StarterGui from a Workspace script? [Solved]

Hi, so recently, I was trying to make my own game that features robot beings trying to come get you, while you have to collect 5 objects in order to beat them. But when you click on an object, it just disappears, and doesn't change the "Objects Left" in the StarterGui, it stays at 5? Anybody know how to fix this?

GIF Of this happening: https://gyazo.com/103f2a4eee89d853d5ebb45d14e4fc82

1 answer

✓ Accepted answer

Changing the StarterGui won't work because the contents of StarterGui are cloned to the player's PlayerGui on spawn. You need to access the player's PlayerGui from a click detector part and change the text label from there. This is how I'd do it:

local object = script.Parent
local objectValue = Instance.new("IntValue", object)

object.ClickDetector.MouseClick:connect(function(player)
	local playerGui = player.PlayerGui
	local gui = playerGui.ScreenGuiName.TextLabelName --change the names
	gui.Text = objectValue.Value + 1
	object:Destroy()
end)

Change the names above to your gui and you're good to go. Let me know if you are confused, I'll explain more.

2 comments

0

Thanks, this helped.

0

Don't forget to put [solved] in the title and accept my answer if it helped you, you'll also gain 2 points to your reputation.

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