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

Making this script a teleport command?

Asked by 7 years ago
Edited 7 years ago

I am having some issues with this. Does anyone see why it will not work? I am not getting any output.



function findPlayer(name) for _, player in ipairs(game.Players:GetPlayers()) do if player.Name:lower() == name:lower() then return player end end end function onChatted(message, player) if message:sub(1, 5) == "to/" then victim = findPlayer(message:sub(6)) player.Character.Torso.CFrame = victim.Character.Torso.CFrame end end game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(message) onChatted(message, player) end) end)

1 answer

Log in to vote
0
Answered by 7 years ago

Sub takes 1 argument, and then an optional second (when called from the string itself. If using the string.sub method, that's a different story). The first should be where to start, and the second where to end. It will give you the string from that "range".

I suggest changing :sub(1, 5) to :sub(1, 3) and :sub(6) to :sub(4) That should fix it

Ad

Answer this question