Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Unable to assign property MeshId. Script write access is restricted ?

I want to changed MeshPart character Id

14:08:15.197 - Unable to assign property MeshId. Script write access is restricted 14:08:15.198 - Stack Begin 14:08:15.199 - Script 'Players.NiniBlackJackQc.PlayerGui.LocalScript', Line 44 - upvalue ScanPlayer 14:08:15.201 - Script 'Players.NiniBlackJackQc.PlayerGui.LocalScript', Line 54 14:08:15.202 - Stack End

--< Services
local PlayerService = game:GetService('Players')

--< Libraries
local MeshNameLibrary = {
	'LeftHand',
	'LeftLowerArm',
	'LeftUpperArm',
	'RightHand',
	'RightLowerArm',
	'RightUpperArm',
	'UpperTorso',
	'LeftFoot',
	'LeftLowerLeg',	
	'LeftUpperLeg',
	'RightFoot',
	'RightLowerLeg',
	'RightUpperLeg',
	'LowerTorso'
}

local MeshIDLibrary = {
	LeftHand = 'rbxassetid://1699715537',
	LeftLowerArm = 'rbxassetid://1699715541',
	LeftUpperArm = 'rbxassetid://1699715550',
	RightHand = 'rbxassetid://1699715557',
	RightLowerArm = 'rbxassetid://1699715562',
	RightUpperArm = 'rbxassetid://169971557',
	UpperTorso = 'rbxassetid://1699715593',
	LeftFoot = 'rbxassetid://1699715602',
	LeftLowerLeg = 'rbxassetid://1699715610',
	LeftUpperLeg = 'rbxassetid://1699715616',
	RightFoot = 'rbxassetid://1699715627',
	RightLowerLeg = 'rbxassetid://1699715632',
	RightUpperLeg = 'rbxassetid://1699715641',
	LowerTorso = 'rbxassetid://1699715652'
	}

--< Functions
local function ScanPlayer(Model)
	for _, v in pairs(Model:GetChildren()) do
		for i, MeshName in pairs(MeshNameLibrary) do
			if v:IsA('MeshPart') and v.Name == MeshName and v.TextureID ~= nil then
				v.MeshId = MeshIDLibrary[v.Name]
				v.TextureID = ''
			end
		end
	end
end

--< Events
PlayerService.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		wait()
		ScanPlayer(Character)
	end)
end)

1 comment

0

You cannot change a MeshPart's MeshId on the fly, because roblox needs to recalculate collisions and such which can't be done at runtime.

1 answer

As the error says, you can’t assign MeshId from a script.

This discussion is preserved as it was. New answers, comments, and votes are closed.