code:
local function click (player) player.PlayerGui.Hosvi.Frame.Visibility = true print("cool") end script.Parent.ClickDetector.mouseClick:connect(click)
I have a click detector in the brick. I click and it does nothing. No output. No print. Nada
please help.
Hello! You have multiple problems in your code that need to be fixed.
First off, please use :Connect
instead of :connect
, as it is deprecated.
Second of all, :MouseClick
is the way to use a click detector.
local function click (player) player.PlayerGui.Hosvi.Frame.Visibility = true print("cool") end script.Parent.ClickDetector.MouseClick:Connect(player)
Now, if you were to do the script above, you would still be having problems.
FilteringEnabled is a setting in which the Client cannot change anything in the Server, which is good to protect against hackers. It is highly recommended to keep this setting turned on, so you would need to use RemoteEvents
to fix your problem.
You want to have a server event tell the client to do something, a.k.a, a ClickDetector
opening a GUI. RemoteEvents help talk to the server about that.
Server Script:
local event = Instance.new("RemoteEvent") event.Parent = game:GetService("ReplicatedStorage") event.Name = "ClickEvent" local function click (player) event:FireClient(player) print("Clicked") end script.Parent.ClickDetector.MouseClick:Connect(click)
LocalScript in StarterPlayer
local player = game:GetService("Players").LocalPlayer local event = game:GetService("ReplicatedStorage"):WaitForChild("ClickEvent") local function clickEvent() player.PlayerGui.Hosvi.Frame.Visibility = true end event.OnServerEvent:Connect(clickEvent)
This should be some working code, if you need any help with getting it to work, or want to know how it works, please ask!