Self explanatory, but I am trying to make a script in where when a player spawns, a decal is placed on their "face".
This is the code I've done so far.
faceid = 2554833537 face = game.player.Character.Head.Insert.new("Decal") game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) if character:WaitForChild("Head") then character.Head.face = "http://www.roblox.com/asset/?id="..faceid end end) end)
What would I need to add and fix?
Thanks in advance
You seem to lack an understanding of how to create new objects in Roblox Lua.
This is done by using:
local newObjectOfClass = Instance.new("Class")
or in your case,
local face = Instance.new("Decal")
Now, onwards from that - in the code that you have provided you create a single instance of your desired decal, not one for each player. To amend this, you need to create the new instance from inside of the specified player's code subsidy.
Consider the following:
game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local face = Instance.new("Decal") end) end)
This way, we will create a new instance of face for each character that is added.
After this, all that's left is to parent the new face instance to the designated character, and apply the desired ID.
local faceInstanceID = "Desired Decal ID" game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) local faceInstance = Instance.new("Decal") faceInstance.Texture = faceInstanceID faceInstance.Parent = Character.Head end) end)
If you have any further questions, don't hesitate to ask.