( Fixed ) Script not working

So I made a button ( part ) so when you click it it makes a button visible. but its not working? I been trying to look dev forum and youtube but nothing helps. am using a script and not local script.

local Player = game.Players.LocalPlayer

local Button = script.Parent.Button

function onClick(click)

Player.PlayerGui.TeleportGui.SecondAreaButton2.Visible = true



1 Like

You need to use a LocalScript to get the LocalPlayer. It is not available for ServerScripts.

Only a local script can call on Localplayer


Pretty sure Clickdetector first parameter is PlayerWhoClicked

ClickDetector.MouseClick returns the player, use it

local Button = script.Parent.Button
	Player.PlayerGui.TeleportGui.SecondAreaButton2.Visible = true

You cannot access LocalPlayer with a server-sided script, instead use MouseClick’s first parameter, which is the player:

local Button = script.Parent.Button

local function onClick(Player)
	Player.PlayerGui.TeleportGui.SecondAreaButton2.Visible = true


its not working? i tried local script

not working as well. i tried that

because u cant put LocalScripts in workspace

its not making the button visible and am not getting errors

Could be you might be referencing correctly.

Could you show us a snippet of your hierarchy?

so how would i make it work? is it possible?

Besides that snippet, is there anything above the code? Maybe that stops it, if there isn’t, above the fragment write print("working"), if it doesn’t print it means that the script is destroyed or inactivated.

I got it to work! I tried something else and it worked

You can hover over LocalScript to see where you can put them