I've already made a "Lightning bolt" which is just a long cilinder part that I've Inserted into Replicated Storage Called "LightningBolt"
Inside the Starter GUI I put this script in a local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local Remote = ReplicatedStorage.LightningEvent
local Mouse = plr:GetMouse()
local Debounce = true
local Key = 'E'
local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://2464206362'
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if IsTyping then return end
local KeyPressed = Input.KeyCode
if KeyPressed == Enum.KeyCode[Key] and Debounce and Char then
Debounce = false
Remote:FireServer(Mouse.Hit)
local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
LoadAnimation:Play()
wait(3)
Debounce = true
end
end)
And in Server Script services I put this script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage.LightningEvent
local Lightning = ReplicatedStorage.LightningBolt
local Damage = 10
local ServerDebounces = {}
Remote.OnServerEvent:Connect(function(plr, Mouse)
if not ServerDebounces[plr] then
ServerDebounces[plr] = true
local Char = plr.Character or plr.CharacterAdded:Wait()
local LightningClone = Lightning:Clone()
Lightning.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0,0,0)
Lightning.Parent = workspace
ServerDebounces[plr] = false
local Debounce = true
LightningClone.Touched:Connect(function(h)
if h.Parent:FindFirstChild('Humanoid') and h.Parent.Name ~= plr.Name and Debounce then
Debounce = false
local Enemy = h.Parent.Humanoid
Enemy:TakeDamage(Damage)
wait(1)
LightningClone.Effect.Enabled = false
wait(1)
LightningClone:Destroy()
Lightning:Destroy()
wait(3)
Debounce = true
end
end)
end
end)
I know that there are still some things that are not needed and I can fix that latter, but I cant wrap my head around how to make the projectile that's pretty long start near me, and the other end where my curser is, this script just brings the middle of the "lazer" and places it infront of me, which isnt where I want it.
I honestly thought just taking away body-velocity and making a projectile script would work, but it seems Im not too bright

3 comments
Format the other part of the code in a codeblock.
I put it in the server script service
Im going to assume though that I'd use raycasting to fix the issue