What I want is for when someone hits a textbutton, It should load a script using Loadstring. I've tried to use MouseButton1Down:connect but it doesn't work. If I could also just use a normal script too without loadstring, that would help. I am using a LocalScript
function Clicked() loadstring(game:GetObjects("rbxassetid://175137115")[1].Source)() end script.Parent.MouseButton1Down:connect(Clicked)
Why won't you just copy the script into your game, and make it so it will only execute if player clicks the text button? like...
Copy the script you're loading to for example, workspace, and then, write this...
game.Players.PlayerAdded:connect(function(player) repeat wait() until player:WaitForChild("PlayerGui") player.PlayerGui.SomeGui.SomeFrame.AtextButton.MouseButton1Click:connect(function() --make the whole code go here? end) end)
script.Parent.MouseButton1Click:connect(function() loadstring(game:GetObjects("rbxassetid://175137115")[1].Source)() end)
If this doesn't work, it's a problem with the loadstring.
Did you forget to enable loadstring? To prevent exploits, loadstring has to be enabled. A property of ServerScriptStorage.
loadstrings cannot be used on the client (localscripts), therefore you will have to hook onto a remoteevent and pass the string as an arguement so you can then convert into a function in a loadstring (LoadStringEnabled must be enabled)
Here, let me correct your code:
function Clicked() loadstring(game:GetObjects("rbxassetid://175137115")[1].Source)() end script.Parent.MouseButton1Click:connect(Clicked)
You cannot run loadstring on the client.
So, you can run this code in a script, or use a RemoteEvent or a RemoteFunction.
Try it out!