I have a script which looks like this:
script.Parent.MouseButton1Click:connect(function() --code is inserted here end)
I am wanting to change the script so that, instead of Script.Parent (a TextButton) triggering the code, 'game.Workspace.Screen' (clickDetector) triggers the code. I have:
game.Workspace.Screen.ClickDetector.MouseClick:connect(function() --same code inserted here end)
Upon clicking, nothing is happening. As soon as I reverted it to the TextButton script, it worked fine. Any help? No errors are outputted.
Why aren't you using script.Parent because if you were using a local script that's probably the problem: The player that clicked the object is passed as the first param of the MouseClick function
script.Parent.ClickDetector.MouseClick:connect(function(player) print(player.Name.." clicked the button.") end)
Ok, by the information given you want a button in workspace, and when clicked, a gui will be modified? Well, you can use players' PlayerGui
. Like so:
game.Workspace.Screen.ClickDetector.MouseClick:connect(function(plr) plr.PlayerGui.ScreenGui.TextButton -- etc end)
Please inform me if I am wrong as I would like to at least try to help out. If this answered your problem, please accept my answer.
Well there you go, I guess it has to be handed with a script. Use RemoteEvents