Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Debris=game:GetService("Debris")
- function raycast()
- local part = owner.Character.Head
- local visual = Instance.new("Part",owner.Character)
- visual.Name = "Ray"
- visual.Color =Color3.fromRGB(255, 255, 127)
- visual.Material = Enum.Material.Neon
- visual.CanCollide = false
- visual.Anchored = true
- visual.CFrame = part.CFrame
- visual.Size = Vector3.new(.1,.1,.1)
- local currentPos = part.Position
- local currentNormal = part.CFrame.LookVector
- local laserdist = 1000
- local function laser(distance)
- local rayp = RaycastParams.new()
- rayp.FilterDescendantsInstances = {owner.Character}
- rayp.FilterType = Enum.RaycastFilterType.Blacklist
- rayp.IgnoreWater = true
- local direction = currentNormal * (laserdist or distance)
- local raycastResult = workspace:Raycast(currentPos,direction)
- local Pos
- if raycastResult then
- Pos = raycastResult.Position
- else
- Pos = currentPos + direction
- end
- local clone = visual:Clone()
- Debris:AddItem(visual,.5)
- clone.Parent = owner.Character
- clone.Size = Vector3.new(.5,.5,(currentPos-Pos).magnitude)
- clone.CFrame = CFrame.new(currentPos:Lerp(Pos, 0.5), Pos)
- Debris:AddItem(clone,.5)
- local oldPos = currentPos
- currentPos = Pos
- if raycastResult then
- local norm = raycastResult.Normal
- local reflect = (currentNormal - (2 * currentNormal:Dot(norm) * norm))
- currentNormal = reflect
- laser(laserdist - (Pos-oldPos).Magnitude)
- return
- end
- end
- laser()
- end
- function Receive(plr,action,obj)
- if action == "Down" then
- raycast()
- end
- end
- local E = Instance.new("RemoteEvent",NLS([[local E = script:FindFirstChildWhichIsA("RemoteEvent")
- local Mouse = owner:GetMouse()
- function ButtonDown()
- if Mouse.Target ~= nil then
- E:FireServer("Down",Mouse.Target)
- end
- end
- function ButtonUp()
- E:FireServer("Up")
- end
- Mouse.Button1Down:Connect(ButtonDown)
- Mouse.Button1Up:Connect(ButtonUp)
- ]],owner.PlayerGui))
- E.OnServerEvent:Connect(Receive)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement