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
no