Hello, My script which is suppose to update the shirt texture of my first person arms based on the player, is not working. Here is my source code any feedback/help would be appreciated, thanks!
Sadly, neither one of them works, every single time the error comes up as,
âShirt is not a valid member of Workspace.ilovedevexâ. Which the problem is that Shirt is a valid member of the playerâs character, because itâs the same for every Roblox character ever.
Now the error, âServerScriptService.CustomShirt:2: attempt to index nil with âCharacterââ comes up when I move it to ServerScriptService in a normal script.
--// Variables //--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Direction = ReplicatedStorage:WaitForChild("ArmModel").Shirt.ShirtTemplate
--// Functions //--
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local ShirtTemplate = Character:FindFirstChild("Shirt").ShirtTemplate
if ShirtTemplate then
Direction.Value = ShirtTemplate.Value
end
end)
end)
I think everything should work fine, but the output has an error which I think has something to do with the server not seeing the ShirtTemplate property.
New error: ServerScriptService.CustomShirt:9: attempt to index nil with âShirtTemplateâ
Alright! I found a solution, put this into StarterCharacterScripts.
--// Variables //--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Direction = ReplicatedStorage:WaitForChild("ArmModel").Shirt.ShirtTemplate
--// Functions //--
local Character = script.Parent
if Character:FindFirstChild("Shirt") then
Direction.Value = Character.Shirt.ShirtTemplate
end
--// Variables //--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Direction = ReplicatedStorage:WaitForChild("ArmModel").Shirt.ShirtTemplate
--// Functions //--
local Character = script.Parent
if Character:FindFirstChild("Shirt") then
Direction = Character.Shirt.ShirtTemplate
end
--// Variables //--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Model = ReplicatedStorage:WaitForChild("ArmModel")
local ShirtModel = Model:WaitForChild("Shirt")
--// Functions //--
local Character = script.Parent
if Character:FindFirstChild("Shirt") and ShirtModel then
ShirtModel.ShirtTemplate = tostring(Character.Shirt.ShirtTemplate)
end
REMINDER
Put the script into StarterCharacterScripts.
The side of the script would be the Server, then make a Script.