Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I Need Help Loadstring Removed?

Asked by 6 years ago

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

0
LocalScripts can’t use loadstring. User#20279 0 — 6y
0
im not useing a local script basstracker1970 -29 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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)
0
do i have to turn on filtering enabled for it to work? basstracker1970 -29 — 6y
0
Yes and no. The remote event allows for the server and client to communicate. User#19524 175 — 6y
Ad

Answer this question