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

My friend made me a custom script?

Asked by 8 years ago

But when I try to change 'run/' it doesn't work when I change it?

current_map = nil

names = {"iSidersz"}

game.Players.PlayerAdded:connect(function(player)
 for i, v in pairs(names) do
  if v == player.Name then 
   player.Chatted:connect(function(chatmsg)
    if chatmsg:sub(1,4) == "run/" then
     local map = chatmsg:sub(5, chatmsg:len())
     if game.Lighting:FindFirstChild(map) then
      if current_map ~= nil then
       current_map.Parent = game.Lighting
      end
      game.Lighting[map].Parent = game.Workspace
      current_map = game.Workspace[map]
     end
    end
   end)
  end
 end
end)
0
For once, not our problem. Bug your friend and ask him about your setup. User#6546 35 — 8y

1 answer

Log in to vote
3
Answered by
Merely 2122 Moderation Voter Community Moderator
8 years ago

Let's look at the code. This line here:

if chatmsg:sub(1,4) == "run/" then

It's checking if the first 4 characters of the chatmsg string are equal to "run/". What you are probably doing when you edit the script is you are changing "run/" to something longer than 4 characters. In that case, you need to update the 4 to the length of the string. The same goes for the 5 in the next line.

A clearer way to do this:

if chatmsg:sub(1, string.len("run/")) == "run/" then
   local map = chatmsg:sub(string.len("run/")+1, chatmsg:len())
0
Ik im stupid for asking this but I have to change run/ to my command right? if so which ones :3 iSidersz 70 — 8y
0
Nvm I figured it out thx merely iSidersz 70 — 8y
Ad

Answer this question