game.Players.PlayerAdded:connect(function(player)
    local id = game.Players:GetUserIdFromNameAsync(player.Name)
    local match = 241708116
    local guard = game.Workspace.Guard1["TG display"]
    local guard2 = game.Workspace.Guard2["TG display"]
    repeat wait() until player.Character
    if id == match then
    local target = player.Character
        while true do
        guard.Humanoid:MoveTo((target.Torso.CFrameCFrame.new(4,0,3)).p, target.Torso)
        guard2.Humanoid:MoveTo((target.Torso.CFrameCFrame.new(-4,0,3)).p, target.Torso)
    wait()
        end
        end
end)

https://gyazo.com/924a29e1c384330e3f4addc3e2f118699

Guard1 and Guard2 are those two models located in that picture. I have two problems, firstly, when I use the ID of my Profile it isn't working in the Studio(When I test it "in-game" there) or in-game, I need to use the ID of the "PLAYER1" profile to get it work in Studio. After maybe that can be fixed somehow, when I try to use either the "PLAYER1" ID or the ID of mine, It's not working however.

They only have the function to basically move behind the target, that's why MoveTo, you know... This script is not really made by me, It's made by a friend of mine for a Star Wars game. He is currently offline so I can only ask here. I would gladly appreciate if you all could help me, somehow.

3 comments

0

It takes longer for everything to load in the game then it does in the studio so, try putting a wait at the beginning of the function or use the :WaitForChild() method.

0

Well, I added the wait but it doesn't really work ingame. Like when I join the game from the website, is the problem the Id? I mean, am I able to change the Id to just Username?

0

Even without the wait it works in the studio, when I use my ID. Like, I use my ID and it works just not when I join from the website. Everything works perfectly fine in the studio but not in the "real" game.