local plr = game.Players.LocalPlayer local InputService = game:GetService("UserInputService") local cam = game.Workspace.CurrentCamera local gocam = false InputService.InputBegan:Connect(function(input) local key = input.KeyCode --Gets the key that the player pressed if key == Enum.KeyCode.Q then --Checks if the key is Q local fly = true local char = plr.Character local i = game.Lighting.death:Clone() i.Parent = workspace local ies = true i.Position = char.Head.Position + Vector3.new(0,4,0) i.Anchored = true i.Name = "Fire" i.CanCollide = true fly = false print("tested") local q = game.Players.LocalPlayer.Character local b = Instance.new("BodyVelocity",i) while ies == true do wait() local mouse = plr:GetMouse() b.MaxForce = Vector3.new(math.huge,math.huge,math.huge) i.CFrame = CFrame.new(i.Position, mouse.Hit.Position) i.Anchored = false b.Velocity = mouse.Hit.LookVector * 23 --q.Head.CFrame.LookVector * 232-- cam.CameraSubject = i end -- damage wont work i:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then -- if a humanoid exists, then humanoid:TakeDamage(23) -- damage the humanoid i:Destroy() -- end
What I'm seeing is that you haven't placed enough end
blocks in your code. Without them, the code is pretty much not able to run right.
local plr = game.Players.LocalPlayer local InputService = game:GetService("UserInputService") local cam = game.Workspace.CurrentCamera local gocam = false InputService.InputBegan:Connect(function(input) local key = input.KeyCode --Gets the key that the player pressed if key == Enum.KeyCode.Q then --Checks if the key is Q local fly = true local char = plr.Character local i = game.Lighting.death:Clone() i.Parent = workspace local ies = true i.Position = char.Head.Position + Vector3.new(0,4,0) i.Anchored = true i.Name = "Fire" i.CanCollide = true fly = false print("tested") local q = game.Players.LocalPlayer.Character local b = Instance.new("BodyVelocity",i) while ies == true do wait() local mouse = plr:GetMouse() b.MaxForce = Vector3.new(math.huge,math.huge,math.huge) i.CFrame = CFrame.new(i.Position, mouse.Hit.Position) i.Anchored = false b.Velocity = mouse.Hit.LookVector * 23 --q.Head.CFrame.LookVector * 232-- cam.CameraSubject = i end end --You need this end to end the previous if statement. end) --Add this "end)" to stop the previous function. -- damage wont work i:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then -- if a humanoid exists, then humanoid:TakeDamage(23) -- damage the humanoid i:Destroy() end end) -- You need this to end a function.
All in all, just make sure you have your ends done. Also, as a side note, Lighting shouldn't be used a storage space, so keep that in mind.
If there's anything else wrong, please let me know so I can fix it!