Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I Need Help Loadstring Removed?

this is my code

http = game:GetService("HttpService")

script.Parent.MouseButton1Down:Connect(function()
pcall(function()
local url = http:GetAsync(script.Parent.Parent.TextBox.Text,true)
if url then
loadstring(url)()
else
error(url)
end
end)
end)

this code works normal in studio put shows no errors and does not work ingame

2 comments

0

LocalScripts can’t use loadstring.

0

im not useing a local script

1 answer

You’re using MouseButton1Click on the server, when it’s client side only. loadstring() is server side only, and so is the HttpService. Use a RemoteEvent and use the RemoteEvent.OnServerEvent event to use the service.

--LocalScript

local button = script.Parent
local textBox = button.Parent.TextBox

button.MouseButton1Click:Connect(function()

    game.Workspace.RemoteEvent:FireServer(textBox.Text)

end)

Now the server side remote event.

local remote = game.Workspace.RemoteEvent

remote.OnServerEvent:Connect(function(plr, url)
    local HttpService = game:GetService"HttpService"
    
    pcall(function()
        local theURL = HttpService:GetAsync(url, true)
        if theURL then
            loadstring(theURL)
        else
            error(theURL)
        end 
    end)
end)

2 comments

0

do i have to turn on filtering enabled for it to work?

0

Yes and no. The remote event allows for the server and client to communicate.

This discussion is preserved as it was. New answers, comments, and votes are closed.