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

When clicking a block with certain name GUI pops up?

Asked by 6 years ago

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

Log in to vote
0
Answered by
CootKitty 311 Moderation Voter
6 years ago

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)
0
It doesnt work and i need it to check blocks inside of models 1234dsaws 0 — 6y
Ad

Answer this question