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

Access PlayerGui From an Onclicked Brick?

so Ive got a brick, when you click it a Gui from StarterGui is supposed to Pop up which holds a bunch of buttons that does stuff, problem is the only way i know how to do this only works in studio.

This is my script

its a local script

local Dice = game.Players.LocalPlayer.PlayerGui.Roller.Window
function onTouched(clicked)
	Dice.Visible = true
end

script.Parent.ClickDetector.MouseClick:connect(onTouched)

Any help on how to rewrite this line to work in a live game?

1 answer

✓ Accepted answer

LocalPlayer can only be called in a localscript INSIDE the player, use this instead:

function onTouched(Player)
	local Dice = Player.PlayerGui.Roller.Window
	Dice.Visible = true
end

script.Parent.ClickDetector.MouseClick:connect(onTouched)

1 comment

0

Thanks, works perfect now

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