My First Person Arms Script Is Not Working

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!

-- // Variables \\ --

local PlayerShirt = game.Players.LocalPlayer.Character.Shirt.ShirtTemplate.Value

-- // Events \\ --

game.ReplicatedStorage.ArmModel.Shirt.ShirtTemplate.Value = PlayerShirt
1 Like

Maybe it won’t work, but try making it the other way around

PlayerShirt = game.ReplicatedStorage.ArmModel.Shirt.ShirtTemplate.Value

Or just

 Game.Players.LocalPlayer.Character.Shirt.ShirtTemplate.Value = game.ReplicatedStorage.ArmModel.Shirt.ShirtTemplate.Value

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.

You must do it through Server Side, from what side are you running the script?

I am running it from, StarterCharacterScripts in a LocalScript, so client.

1 Like

Alright, try running it from the server side; otherwise it will only replicate on the client side.

Now the error, “ServerScriptService.CustomShirt:2: attempt to index nil with ‘Character’” comes up when I move it to ServerScriptService in a normal script.

From Server-Side would be;

--// 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)

Let’s see if it works fine.

1 Like

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
1 Like

Under a LocalScript or a normal Script?

This would be from Server-Side, so a Script it’s fine.

1 Like

For some reason, I think it seems to not see Value as a proper property.

New Error: Workspace.ilovedevex.CustomShirt:9: attempt to index string with ‘Value’

also, sorry for all the questions. :sweat_smile:

--// 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

Let’s test this!

1 Like

This is a weird one, no errors, but no changes either. :thinking:

--// 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.
1 Like

Thank you so much, it worked! I couldn’t have done it without you! :smile:

1 Like

Nice, it worked! Have a nice day programming.

1 Like