Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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)
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. Amiaa16 3227 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

Ad

Answer this question