Script to show billboard gui works, but on a global scale. I need this to be local, help me out!

Hello! So this is a script that, when clicked makes a surfaceGui appear. It does work, but I need it to be on a local scale so only the player clicking can see it. I tried putting the following into a LocalScript as opposed to a script but it just meant the entire thing didn’t work. Can someone please help me out? Thanks!

local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseClick:Connect(function(plr)
	script.Parent.Attacks.Tribrid.Visible = true
end)

It should work as intended, but you’ll need to have the LocalScript parented under something that it is allowed to run under. That could could be the player’s character, their backpack, their PlayerScripts folder, etc., but if the BillboardGui isn’t under any of those places, the script won’t run. In that case, you’d need just need to move the script and change your references.

1 Like

You can try using RemoteFunctions or RemoteEvents if running the code on a LocalScript does not work.

RemoteFunction:
Place a RemoteFunction inside of ReplicatedStorage
Now place a server script inside of ServerScriptService and insert this

local ClickDetector = script.Parent.ClickDetector

ClickDetector.MouseClick:Connect(function(plr)
         game.ReplicatedStorage.RemoteFunction:InvokeClient(plr)
end)

Now place a local script inside of StarterPlayerScripts which is located in StarterPlayer

game.ReplicatedStorage.RemoteFunction.OnClientInvoke = function(plr)
        game.Workspace.SurfaceUi1.SurfaceUi2.SurfaceUi3.Visible = true
end

I hope this helps.

1 Like

As someone else has said, you would need to fire client or equivalent, assuming the clickdector only works in a server script.

Let me know if you have ran into an error whilst using the codes above or if it helped, I am happy to help fix any mistakes.

1 Like

I wouldn’t recommend using RemoteFunction for Server → Client communication in any situation. It can cause script to error, unneccessary yield, etc.