I am making a lightbeam and i wanted to put it in a script not a local script, so i took the code form the local script and out it in a script. It says mouse is no longer active??
here is the script:
local Tool = script.Parent local player = game:GetService("Players") local Character = player.Character local en = true Tool.Equipped:Connect(function(mouse) print("Tool equipped!") if not en then return end en = false Tool.RemoteEvent:FireServer(mouse.Hit) wait(.5) en = true Tool.Activated:Connect(function() print("Mouse pressed!") local ray = Ray.new(Tool.Handle.CFrame.p, (mouse.Hit.p - Tool.Handle.CFrame.p).unit * 300) local part, position = workspace:FindPartOnRay(ray, player.Character, false, true) local beam = Instance.new("Part", workspace) beam.BrickColor = BrickColor.new("New Yeller") beam.FormFactor = "Custom" beam.Material = "Neon" beam.Transparency = 0.25 beam.Anchored = true beam.Locked = true beam.CanCollide = false local distance = (Tool.Handle.CFrame.p - position).magnitude beam.Size = Vector3.new(.5, .5, distance) beam.CFrame = CFrame.new(Tool.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2) game:GetService("Debris"):AddItem(beam, 1) if part then local humanoid = part.Parent:FindFirstChild("Humanoid") if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end if humanoid then humanoid:TakeDamage(30) end end beam.Touched:Connect(function(hit) local Sound = Instance.new("Sound") Sound.SoundId = "rbxasset://sounds//Rocket shot.wav" Sound.Parent = player.Character.HumanoidRootPart Sound.PlaybackSpeed = 1 Sound.Volume = .5 Sound.MaxDistance = 500 Sound:Play() if not en then return end en = false for i = 1,10 do local Explosion = Instance.new("Part") Explosion.BrickColor = BrickColor.new("New Yeller") Explosion.Shape = Enum.PartType.Ball Explosion.Material = "Neon" Explosion.FormFactor = "Custom" Explosion.Transparency = 0.25 Explosion.Size = Vector3.new(50,50,50) Explosion.CanCollide = false Explosion.Anchored = true Explosion.Locked = true Explosion.CFrame = beam.CFrame Explosion.Parent = game.Workspace game.Debris:AddItem(Explosion,1) wait(0.005) Explosion.Size = Vector3.new(55,55,55) wait(0.005) Explosion.Size = Vector3.new(58,58,58) wait(0.005) Explosion.Size = Vector3.new(60,60,60) wait(0.005) Explosion.Size = Vector3.new(65,65,65) wait(0.005) Explosion.Size = Vector3.new(70,70,70) wait(0.005) Explosion.Size = Vector3.new(75,75,75) wait() en = true end end) end) end)