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!