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

LoadString doesn't function in the workspace?

I have this localscript that basically clones another script like this:

local input = script.Parent:WaitForChild("sb").editor.main
local run = script.Parent:WaitForChild("sb").run
local stop = script.Parent:WaitForChild("sb").stop
local save_load = script.Parent:WaitForChild("sb").save
local console = script.Parent:WaitForChild("sb").console
local head = script.Parent:WaitForChild("sb").head
local plr = game.Players.LocalPlayer
local count = 0
local closer = script.Parent.sb.closer
run.MouseButton1Down:Connect(function()
	count = count + 1
	local s = workspace.TEMP:Clone() --Cloning the script
	s.Parent = game:GetService("Workspace")
	print(s.Parent) --returns Workspace
	s.ss.Value = input.Text
	print(input.Text,s.ss.Value) --returns print("test")
	s.Name = plr.Name.."_script"..count
	print(s.Name) --returns PyccknnXakep_script1 
	s.Disabled = not s.Disabled
	print(s.Disabled) --returns false
	--checker
	if game:GetService("Workspace"):FindFirstChild(plr.Name.."_script"..count) then
		print("script found") --returns script found
	else
	print("attempting to make another") --doesnt return
	local s = script.Parent.Script:Clone()
	s.Parent = game:GetService("Workspace")
	s.source.Value = input.Text
	s.Name = plr.Name.."_script"..count
	s.Disabled = not s.Disabled
	end
end)
stop.MouseButton1Down:Connect(function()
	if count <= 0 then
		return warn("Please create a script before deleting it!")
	end
	local s2find = workspace:FindFirstChild(plr.Name.."_script"..count)
	if s2find then
	count = count - 1
	s2find:Destroy() --destroys the script 
	else return end
end)

Inside of the server script that is cloned:

wait()
loadstring(script.ss.Value)()

The weird thing is the script clones and everything, but the script doesn't load the value. Yes, LoadStringEnabled is turned on and so is FilteringEnabled. Any help?

1 answer

✓ Accepted answer

Oh, I got it. The value will only appear for the client, and not the server. So the server still sees the value as blank. Instead, use RemoteEvents.

11 comments

0

How so?

0

Because since you changed the value on the client side, only the client will see it. The server will not see it nor the other clients.

0

Yeah but if the client sees it then why doesnt it load the string?

0

Because the server is loading the string, not the client.

0

Could you show me how to make it so it works throughout the server?

0

I know how to use remote events, I just don't know how to use them in this case.

0

Send the info what you want to be run using Remote events.

0

How could I send a script, as a string, in a remote event? And what would the remote event do? Change the value of the stringvalue inside of the script? Keep in mind i need to destroy the cloned script aswell.

0

Don't you remember how I made the client send info to the server to run in my game? https://pastebin.com/1FSCUKsV

0

Unfortunately, no, I don't remember. But this should work, I'll now redo my code now. Thanks!

0

Could I make it stop though?

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