Hi, Recently I had made a script that summons a lightning bolt. The only issue is that my lightning bolt can only face one direction. So say my player was facing west and I summon a lightning bolt, the lightning bolt would face North. How can I fix this issue?
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 orientation = character.HumanoidRootPart.Orientation
local Workspace = game.Workspace
local target
local God = player.PlayerGui.ChooseCharacter.God
--BREAKLINE--
local function onKeyPress(actionName, userInputState, inputObject)
target = mouse.Target
if userInputState == Enum.UserInputState.Begin then
if inputObject.KeyCode.Name =="Z" then
if God.Value =="Zeus" then
game:GetService("Chat"):Chat(player.Character.Head, "EAGLE SUMMON","Blue")
print("Test Z")
end
end
if inputObject.KeyCode.Name =="T" then --THIS IS MASTERBOLT SUMMON--
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()
end
end
if inputObject.KeyCode.Name =="F" then --THIS IS ULTIMATE ABILITY--
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 --THIS IS LIGHTNING DASH--
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
if inputObject.KeyCode.Name =="E" then --THIS IS WERE I NEED HELP--
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("SpecialMesh",Thunder)
mesh.MeshId = "rbxassetid://978945957"
mesh.TextureId = "rbxassetid://978945981"
Thunder.Anchored = true
Thunder.Orientation = Vector3.new(orientation)
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()
else
print("FAIL THUNDERBOLT")
end
if inputObject.KeyCode.name =="Z" then
if God.Value =="Zeus" then
game:GetService("Chat"):Chat(player.Character.Head, "EAGLE FLIGHT!","Blue")
else
print("Fail EagleSummon")
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
)

6 comments
lookvector
To use lookvector, I just do lookvector.new?
No
Im really confused I tried to use lookVector but I had an error:21:02:13.224 - ContextActionService: Unexpected error while invoking callback: CFrame is not a valid member of SpecialMesh
CFrame.new(Vector3 pos, Vector3 lookAt)
CFrame isn't a property of SpecialMesh object. Get the CFrame of the parent of the special mesh or use a meshpart instead of the special mesh.