So i want to run a function when a part is clicked, but i didn't use ClickDetector because.. they're outdated and no one uses them and they also don't work. So what i did was when the player had their mouse over on it, and he/she clicked on it it would open a GUI.
IF YOU HAVE A SHORT ANSWER, PLEASE FILL IT IN AS AN ANSWER, NOT COMMENT!
I wrote the script in a GUI in a LocalScript and here's what i wrote:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function()
if Mouse.Target == "ClickerForPlanet" then
script.Parent.Menu.Visible = true
end
if Mouse.Target == "ClickerForPlanet2" then
if workspace.ClickerForPlanet2.PlanetPurchased.Value == true then
script.Parent.Menu2.Visible = true
end
end
end)
A similar script that i tried was:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function()
if Mouse.Target == worksapce.ClickerForPlanet then
script.Parent.Menu.Visible = true
end
if Mouse.Target == worksapce.ClickerForPlanet then
if workspace.ClickerForPlanet2.PlanetPurchased.Value == true then
script.Parent.Menu2.Visible = true
end
end
end)
--NOTE--
--The ClickerForPlanet is a part, not a ClickDetector.
------------
I tried both of them, and none of them worked. What can i do?? I'll take any answer.
Thank you so much for helping! ~Chez_Guy :)
IF YOU HAVE A SHORT ANSWER, PLEASE FILL IT IN AS AN ANSWER, NOT COMMENT!

5 comments
ClickDetectors work and are widely used, they have also been updated to work with FE. Using a ClickDetector is your best option.
Ok, I'll try it out @kingdom5 (also i dont think everyone reads the bold i know understand..)
"inserts a part with a script and click detector" WHAT DO YOU MEAN THEY DON'T WORK
To make it even more hidden, just turn the CursorIcon to rbxasset://textures/advCursor-white.png
You could add a tool to the backpack and use onActivated and get the mouses target