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

Why dosen't this script work?

Asked by 9 years ago

I'm trying to make a GUI show up on a player who clicks on the brick, I have a clickdetector and all, and this is in a LocalScript. Code :

local Clicker = script.Parent.ClickDetector
local player = game.Players.LocalPlayer

Clicker.MouseClick:connect(function(player)
    game.StarterGui.PurchaseFarmGui.Frame.Visible = true
end)

1 answer

Log in to vote
0
Answered by
ItsMeKlc 235 Moderation Voter
9 years ago

First off, you cant use LocalPlayer due to this most likely being in a regular script, but luckily for us, click detectors recognize the player who clicked it. Secondly, on line five the script is editing the source GUI, not the one that has been replicated to the player. So try this:

local Clicker = script.Parent.ClickDetector

Clicker.MouseClick:connect(function(player)
      player.PlayerGui.PurchaseFarmGui.Frame.Visible = true
end)


0
Thanks ;) KennySfromTitan 106 — 9y
0
Can you accept the answer please? :) ItsMeKlc 235 — 9y
Ad

Answer this question