Access the LocalPlayer in Workspace?

Attempting to change a players face when they join the game. Does anyone know how to access the local player in Workspace?

This is the code so far,

local player = game.Players.LocalPlayer.Character

if player:findFirstChild("Humanoid") then
    player.Head.face.Texture = "http://www.roblox.com/asset/?id=4623132478"
end

It’s meant to find the player in Workspace and access their face’s decal texture. Did I write this correctly?

2 Likes

So, is this a local script or a script? Do you have Filtering Enabled to true or false? also, if this is a local script in workspace, it’s not going to work!

If you’re running this correctly on the client side, it may be a loading issue. I would recommend using a server script like this in ServerScriptService so that other players can see

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		repeat wait() until char
		char.Head.face.Texture = ""
	end)
end)
2 Likes

Regardless of it being disabled in the properties, it is still set to true. Roblox has forced filtering enabled and there is no way to disable it.


@BIueMalibu local scripts cannot run in workspace. The only exception is when they’re a descendant of a players character. Local scripts only run when they’re a descendant of a player, or their character, or in replicated first.

Make this a server script and instead listen for the PlayerAdded and CharacterAdded events:

game:GetService("Players").PlayerAdded:Connect(function(client)
    client.CharacterAdded:Connect(function(character)
        character:WaitForChild("Head").face.Texture = "http://www.roblox.com/asset/?id=4623132478"
    end)
end)
2 Likes

It is a local script.

30characterlimit

It’s a local script that I put in ServerScriptService

Local scripts cannot run in there either. Think about it. ServerScriptService. Make it a server script, and using the code I provided works.

Ohhhh, I assumed since I only wanted it to affect the local player it should be a local script. Thank you for this info.

1 Like

A localscript will not run in ServerScriptService. It should be a descendant of:

  • The player character

  • The player’s PlayerGui

  • The player’s PlayerScripts

  • Or the player’s Backpack
    There may be other places but only regular scripts can run in ServerScriptService.

1 Like

As everyone else mentioned, because it’s a local script in ServerScriptService, it won’t work.

A script-less alternative is via Studio’s Game Settings Avatar tab. You can force a face from there. However, using a script of course allows for much more customization and control in the future.

1 Like

I dont know what you mean? Players get a copy of the local script, so the changes would have been applied to everyone locally. You wouldn’t see the face change on someone else, but you would for yourself.

My code replicates the changes to everyone since it is server script.

Also remember that the server has no concept of “local player” so don’t use that term in server context.

It works now, thank you very much.

1 Like

just put that code in StarterCharacterScripts