Haven't played ROBLOX since 2014 really and a lot has changed, so could someone help me with what is going wrong here?
function onChatted(msg,speaker) if (string.sub (msg,1,10) == "duel/" then ---you say this first and then the players name p = game.Players:GetChildren() ---finds player for i=1, #p do ---the players that to start if p[i].Name == string.sub(msg,11) then ---the player name m = Instance.new ("Message") ---creates a message m.Parent = p[i].Character ---sends it to the requested player m.Text = ""..speaker.Name.."has challenged you! Type accept/ to Fight or Decline/ to decline " ---speaker.Name is the player requested wait(30) ---waits 30 seconds for it to reply, if he/she doesn't it removes m:Remove() end end ---ends the script/line. end if (string.sub (msg,1,7) == "accept/") then ---if the player accepts... p = game.Players:GetChildren() for i=1, #p do if p[i].Name == string.sub(msg,8) then if (m ~= nil) then m:Remove() speaker.Torso.CFrame = CFrame.new (Vector3.new (109.521, 76.298, -246.288)) ---change these numbers on where the speaker teleports f = Instance.new ("Message") f.Parent = p[i].Character f.Text = ""..speaker.Name.."has accepted your challenge!" ---message sent to the speaker :D wait(2) f:Remove() p[i].Character.Torso.CFrame = CFrame.new (Vector3.new (114.04, 75.519, -272.141)) ---change these numbers on where the other player teleports end end ---ends? end end if (string.sub (msg,1,8) == "decline/") then ---decline? Hes scared xD p = game.Players:GetChildren() for i=1, #p do if p[i].Name == string.sub(msg,9) then z = Instance.new ("Message") z.Parent = p[i].Character z.Text = ""..speaker.Name.."has declined your challenge!" ---sends to the requester end end end ---ends the whole entire script end function onPlayerEntered(newPlayer) ---makes this work with every player that enters newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) end) ---connects with the players end game.Players.ChildAdded:connect(onPlayerEntered)