How to use loadstrings?

You can use string.split for this. Make sure LoadstringEnabled is enabled (in ServerScriptService). It may be risky to have enabled in some cases.

local Players = game:GetService('Players')
local Prefix = ':'

Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		local Splits = Message:split(' ')
		local String
		
		if Splits[1]:lower() == Prefix .. 'execute' then
			if Splits[2] and Splits[2]:find('%w') then
				table.remove(Splits, 1) -- Remove the first argument from the table
				String = table.concat(Splits, ' ') -- Include everything except the actual command name
				loadstring(String)()
			end
		end
		
	end)
end)

This SHOULD be a server script. You don’t need a localscript.

38 Likes