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

what does unable to assign property meshid. Script write access is restricted mean?

Hi, I made a script were when you click E, a lightning bolt appears in front of your character. The lightning bolt is a meshpart, and just recently I added lookVector to it.

But when I tried to summon a lightning bolt this error appeared

18:38:26.923 - ContextActionService: Unexpected error while invoking callback: Unable to assign property MeshId. Script write access is restricted

Is there anyway for me to fix it?

Here is my script:

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:Wait() 
local head = character:WaitForChild("Head")

local Humanoid = character:WaitForChild("Humanoid")
local torso = character.UpperTorso
local mouse = player:GetMouse()

local bodyparts = game.Players.LocalPlayer.Character:GetChildren()


local Workspace = game.Workspace





local God = player.PlayerGui.ChooseCharacter.God
--BREAKLINE--

local function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
	
	if inputObject.KeyCode.Name =="Z" then 
		if God.Value =="Zeus" then
			game:GetService("Chat"):Chat(player.Character.Head, "CHARIOT","Blue")
			print("Test Z")
		elseif God.Value =="Poseidon" then --SUMMON HORSE(POSEIDON)--
			game:GetService("Chat"):Chat(player.Character.Head, "CHARIOT","Blue")
		end
	end
	
	if inputObject.KeyCode.Name =="T" then  
		if God.Value =="Zeus" then
			game:GetService("Chat"):Chat(player.Character.Head, "MASTERBOLT!","Blue")
			local tool = game.Workspace.BetaBolt:Clone()
			character.Humanoid:EquipTool(tool)
			wait(5)
			tool:Destroy()
		elseif God.Value =="Poseidon" then --summon trident--
			game:GetService("Chat"):Chat(player.Character.Head, "TRIDENT!","Blue")
			
		end
	end
	
	  
	
	   if inputObject.KeyCode.Name =="F" then
		if God.Value =="Zeus" then
		game:GetService("Chat"):Chat(player.Character.Head, "FEEL THE POWER OF A TRUE GOD!","Blue")
		Humanoid.HipHeight = 20
		
		
		for _,body in pairs(bodyparts) do
    if body.Name == "RightHand" then 
        body.BrickColor = BrickColor.new("Dark blue") 
    end
		end
		
		
	    local lightning = Instance.new("Part",Workspace)
	    lightning.Shape = ("Cylinder")
		lightning.BrickColor = BrickColor.new("Institutional white")
		lightning.Transparency = 0.5
		lightning.CanCollide = false
		lightning.Size = Vector3.new(2, 9, 5)
	
	
		wait(6)
        --end of power--

		Humanoid.HipHeight = 1.35
		end
	end
	
	
	if inputObject.KeyCode.Name =="Q" then 
		if God.Value == "Zeus" then
			game:GetService("Chat"):Chat(player.Character.Head, "LIGHTNING DASH!","Blue")
			head.CFrame = head.CFrame * CFrame.new(0,0,-50)
		else
			print("FAIL LIGHTNING DASH")
	  
		end
	end
	
	
         --THIS IS THE THUNDERBOLT PART WERE I NEED HELP--

	if inputObject.KeyCode.Name =="E" then 
		 if God.Value == "Zeus" then  
            game:GetService("Chat"):Chat(player.Character.Head, "THUNDER!","Blue")
            local damage = game.Workspace.Damage:Clone()
            local Thunder = Instance.new("Part")
            Thunder.Name = ("ThunderBolt")
            local mesh = Instance.new("MeshPart",Thunder)
            mesh.MeshId = "rbxassetid://978945957"
            mesh.TextureId = "rbxassetid://978945981"
            Thunder.Anchored = true
            
        
            mesh.CFrame.lookVector = character.CFrame.lookVector
            mesh.Scale = Vector3.new(5,20,15)


            damage.Position = Vector3.new(mouse.hit.x,mouse.hit.y,mouse.hit.z)
            damage.Parent = workspace
            Thunder.Position = Vector3.new(mouse.hit.x,mouse.hit.y,mouse.hit.z)
            Thunder.Parent = workspace
            wait(1)
            damage:Destroy()
            Thunder:Destroy()
 

	
		end
		
		
	if inputObject.KeyCode.name =="Z" then
		if God.Value =="Zeus" then
		game:GetService("Chat"):Chat(player.Character.Head, "EAGLE FLIGHT!","Blue")
		       else

		end
	end
		
		
        

        end
    end
end

game:GetService("ContextActionService"):BindAction(
    "keyPress", 
    onKeyPress, 
    false, 
    Enum.KeyCode.Q,
    Enum.KeyCode.E,
    Enum.KeyCode.F,
    Enum.KeyCode.T,
    Enum.KeyCode.Z
)

1 comment

0

no

3 answers

The reason for this is because, as the error says, script write access is restricted. The MeshId property is an fbx file which is downloaded to the computer and then you set the MeshId and stuff. It cannot be written because developers would have to access their player's files, which is a big security hazard. For this reason, MeshId cannot be written from scripts. Though you can store the mesh somewhere and then clone it whenever you need it.

4 comments

0

so if I clone the mesh, then I can use lookVector?

0

isnt instance.new the same as cloning?

0

no

0

Oh, do you mind if you can see whats wrong with my script. Scroll down to see it.

I tried to make thunderbolt, a clone and then set its lookVector to the players lookVector, but this error keeps on popping up.

20:06:31.402 - ContextActionService: Unexpected error while invoking callback: lookVector cannot be assigned to

Here is what I tried:

local Thunder = game.Workspace.ThunderBolt:Clone()
Thunder.CFrame.lookVector = character.Head.CFrame.lookVector

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