Basically, I have a script and a BodyGyro in a part. The part is not anchored or cancollide, but it has a BodyPosition object to hold it in place. What I want to do is have the part always face the player (I'm going to make it a local part so each player sees it face them, but that's later). However, whenever I run the script in solo, it does not make the object face the player, but throws no errors. Why is this?
game.Players.PlayerAdded:connect(function(plr) while plr do wait() player = game.Players:GetPlayerFromCharacter(plr) if player then script.Parent.BodyGyro.cframe = CFrame.new(player.HumanoidRootPart.Position) end end end)
Thank you for any feedback, advice, or changes you have.
This is incorrect in a way that first, the "GetPlayerFromCharacter" isn't needed, because the player is "plr", if you want the character, say "player = plr.Character". The correct should be:
game.Players.PlayerAdded:connect(function(plr) while plr do wait() player = plr.Character if player then script.Parent.BodyGyro.CFrame = CFrame.new(player.HumanoidRootPart.Position) end end end)
Does anyone have a solution? This has been bothering me for quite some time.