Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Access PlayerGui From an Onclicked Brick?

Asked by
nicros 165
8 years ago

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

Log in to vote
1
Answered by 8 years ago

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)

0
Thanks, works perfect now nicros 165 — 8y
Ad

Answer this question