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

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

Asked by 1 year ago
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.

0
You're using LocalPlayer which you can't do in a server script. MattVSNNL 620 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

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)
Ad

Answer this question