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

could someone help me on a ui click brick it not working.?

Asked by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

Here's my script.

local clickDetector = script.Parent
local brickClickedEvent = game.ReplicatedStorage.Events.BrickClicked

clickDetector.MouseClick:Connect(function(player)
        brickClickedEvent:FireClient(player)
        print(player.Name.. "has clicked the brick")
         game.StarterGui.TableFinder.Enabled = true
    end
end)

the GUI won't appear help?

everything is in the correct place.

2 answers

Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

You are using the wrong location to find the gui element, try this:

local clickDetector = script.Parent
local brickClickedEvent = game.ReplicatedStorage.Events.BrickClicked
local player = game.Players.LocalPlayer

clickDetector.MouseClick:Connect(function(player)
    if not false then
        brickClickedEvent:FireClient(player)
        print(player.Name.. "has clicked the brick")
        player.PlayerGui.TableFinder.Enabled = true
    end
end)

Also, a more simple way to do it is to make the gui's visibility false. If you do that way, use this:

local clickDetector = script.Parent
local brickClickedEvent = game.ReplicatedStorage.Events.BrickClicked
local player = game.Players.LocalPlayer

clickDetector.MouseClick:Connect(function(player)
    if not false then
        brickClickedEvent:FireClient(player)
        print(player.Name.. "has clicked the brick")
        player.PlayerGui.TableFinder.Visible= true
    end
end)
Ad
Log in to vote
0
Answered by 4 years ago

instead of changing screen gui, use a localscript in startergui which on an event changes game.Players.LocalPlayer.PlayerGui.YourGui to enabled/disabled

Answer this question