i was wondering if anybody had any ideas on the best/easiest/most efficient way to script or go about this? i really just need advice on placing the sprites on the player and having them change for whatever direction they’re facing. thank you!
Probably make the player invisible, attach a BillboardGui to the HumanoidRootPart (or any other part on the character) then get the relative direction between the camera and character ( CameraCFrame:ToObjectSpace(PlayerCFrame) ), then change the sprite based on that.
do you have a really simple way to make the player invisible upon joining? i’ve tried different scripts to no avail. bare with me because i havent scripted in a super long time
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Connect(function(character)
for i,v in pairs(character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart")then
v.Transparency = 1
end
end
end)
player:LoadCharacter()
end)
this code is not well written, and this is a quick and dirty solution but it seems to work fine. i dont recommend using this code permanently though
that only runs when the player joins the game for the first time, it is just in case the character loads before the game sees the characterappearanceloaded event. just to make sure that gets run
yeah, it isnt a good solution to the problem though, and there are better ways of doing it. i just wanted to get a reply quickly. this problem only usually happens on bigger games though, that lag more
local Players = game:GetService("Players")
function CharacterAdded(character)
for i,v in pairs(character:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart")then
v.Transparency = 1
end
end
end
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAppearanceLoaded:Connect(function(Character)
CharacterAdded(Character,Player)
end)
local Character = Player.Character
if Character then -- If the character already exists, the CharacterAdded event probably didn't fire until now.
CharacterAdded(Character,Player)
end
end)
in fact, this might be a better code snippet. however i havent tested this
thank you guys very much for all of the scripts and advice!! i tried test account’s scripts and i can’t seem to get them to work however i might be putting them in the incorrect place. i also tested the rig which works but i’m unable to move for whatever reason
i chose a random rig from the toolbox to test and it does seem to have hrp. still unable to move however. i tested another one with the same issue. i also tried to use the script in sss and it still can’t seem to get it to function.
You’re misunderstanding; the HRP missing is not the problem. If you select and observe the properties of the HRP, it should be anchored, since that’s the default state that rigs are made with. Unanchor it and you should find your movement.
hey! so i’ve been trying this out and the billboardgui thing works great! however i’m having issues when it comes to the actual walking animations according to which way the player is walking. i started another thread for this issue if you want to respond there as there is more context, but here is a dummy script i made which i’m sure has a lot of issues but i can’t figure out what to change. note: my camera is already fixed with another script in order to give it the top down kind of view.
local image = script.Parent.ImageLabel
local anims = image:GetChildren()
local hrp = script.Parent.Parent
local rightw1 = image:GetChildren("RightWalk1")
local rightw2 = image:GetChildren("RightWalk2")
local camera = game.Workspace.CurrentCamera
local humanoid = hrp
if (humanoid.MoveDirection:Dot(camera.CFrame.RightVector) > 0.75) then
image.Image = rightw1
wait(.5)
image.Image = rightw2
wait(.5)
end
it may be easier to go off of the players movement direction in relation to the camera.
what i mean is that if the camera is facing forwards, and the character is facing backwards, have the sprite face the camera, but if the camera is facing forwards and the character is facing forwards, then show the back of the character instead
(i apologize if this is what you are already doing, i only skimmed over the last few posts)