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

what im trying to do, is when someone with a specific userid chats, I get teleported to them. ?

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
    if player.UserId == 155568503 then
        player.Chatted:Connect(function(message)
            if message == "rights" then
                game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame
            end
        end)
    end
end)

this is for roblox lua.

1 comment

0

You're using LocalPlayer which you can't do in a server script.

1 answer

You're using LocalScript

Script in ServerScriptService:

local TargetId = 155568503
local CreatorId = game.CreatorId -- or your UserId
local Pass = "rights"
game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if plr.UserId == TargetId then
			if msg.lower() == Pass then
				for i,creator in pairs(game.Players:GetPlayers()) do
					if plr.UserId == CreatorId then
						creator.Character.HumanoidRootPart.CFrame = plr.Character.HumanoidRootPart.CFrame
					end
				end
			end
		end
	end)
end)

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