Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

When clicking a block with certain name GUI pops up?

Im trying to make a script that if you click a block with the name "Touch" A gui pops up, This is what i have so far but its only if i click one block not any

game.Workspace:FindFirstChild(script.Parent.Value.Value).Click.ClickDetector.MouseClick:connect(function()
	game.Players.LocalPlayer.PlayerGui.Buy.Visible = true
end)

1 answer

Use a local script located in someplace like ReplicatedFirst, and use the mouse property of the player.

-- Local Script in ReplicatedFirst

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

local gui = plr:WaitForChild("PlayerGui"):WaitForChild("Buy") -- buy should be one of those ScreenGuis or whatever, I assume

mouse.Button1Down:Connect(function()
    local target = mouse.Target
    if(target.Name=="NAME HERE")then
        gui.Enabled = true -- if screenGui I think the property is Enabled, else make sure the GUI is in a ScreenGui or it won't be displayed.
    end
end)

1 comment

0

It doesnt work and i need it to check blocks inside of models

This discussion is preserved as it was. New answers, comments, and votes are closed.