I’ve enabled loadstring(), but however it is not working at all.
Code:
game.UserInputService.InputBegan:Connect(function(inputObject, gameProcess)
if gameProcess then return end
if inputObject.KeyCode == Enum.KeyCode.Semicolon then
script.Parent.Parent:TweenPosition(UDim2.new(0.125, 0, 0.125, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.5, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
script.Parent.Text = ""
task.wait(0.5)
script.Parent:CaptureFocus()
end
end)
script.Parent.FocusLost:Connect(function(EnterPressed)
if not EnterPressed then return end
script.Parent.Parent:TweenPosition(UDim2.new(0.125, 0, -0.125, 0), Enum.EasingDirection.In, Enum.EasingStyle.Back, 0.5, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
local LoadedString = loadstring(script.Parent.Text)
LoadedString()
print "Done!"
end)
As stated by @MichaAndersan, you should add a bracket at the end to execute the thread. Your script seems to be client sided aswell, loadstrings only work in server scripts for security and reliability.
Like the others said, loadstring only works on the server, and you can fix this by sending the text to the server and running it on the server. However I’d like to point out that this can put your game and account at risk. Anyone will be able to run code which can allow people to create TOS breaking content which will get the game and your account banned.
I’ve removed loadstring() inside the client script and put it inside a BindableEvent inside ReplicatedStorage, but it does NOT work!
BindableEvent’s code:
--!nocheck
script.Parent.Event:Connect(function(Script)
loadstring(Script)()
print("checking to see if this works :D")
end)
Client’s code:
game.UserInputService.InputBegan:Connect(function(inputObject, gameProcess)
if gameProcess then return end
if inputObject.KeyCode == Enum.KeyCode.Semicolon then
if game.Players.LocalPlayer.Name == "DomonicJ06" or game.Players.LocalPlayer.Name == "error12345307" or game.Players.LocalPlayer.Name == "Dragon_head2346" then
script.Parent.Parent:TweenPosition(UDim2.new(0.125, 0, 0.125, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Back, 0.5, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
script.Parent.Text = ""
task.wait(0.5)
script.Parent:CaptureFocus()
end
end
end)
script.Parent.FocusLost:Connect(function(EnterPressed, Input)
if not EnterPressed then return end
game.ReplicatedStorage.LoadString:Fire(script.Parent.Text)
script.Parent.Parent:TweenPosition(UDim2.new(0.125, 0, -0.125, 0), Enum.EasingDirection.In, Enum.EasingStyle.Back, 0.5, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
print "Done!"
end)
BindableEvents only fire on the same side of the server-client boundary. In this case, it’s still trying to loadstring on the client. Use a RemoteEvent and make the event handler a Script so it’s ran on the server.
You need to use a RemoteEvent for this, not a BindableEvent as bindable events fire on the same environment they are called in (client or server), however RemoteEvents can send messages from the client to the server and vice versa.