Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Constants
- local SHADOW_RAY_LENGTH = 40
- local MAX_MOUSE_DISTANCE = 150
- --Waits until Character is Loaded
- repeat wait() until game.Players.LocalPlayer.Character
- --Variables
- local Player = game.Players.LocalPlayer
- local Character = Player.Character
- local rayDirection = game.Lighting:GetSunDirection() --Gets where the Sun is at
- local Mouse = Player:GetMouse()
- --Remote Events
- local shadowEvent = game.ReplicatedStorage.Events:WaitForChild("RougeShadow")
- --Function to Check If You Can Teleport
- local function checkRays()
- --Filter to Exclude The Player's Character From Ray
- local v1 = RaycastParams.new()
- v1.FilterDescendantsInstances = {Character}
- v1.FilterType = Enum.RaycastFilterType.Blacklist
- --Making a Ray to See if Anything Hits
- local shadowRay = workspace:Raycast(Character.HumanoidRootPart.Position,(rayDirection * SHADOW_RAY_LENGTH),v1)
- local checkMouseRay = workspace:Raycast(Mouse.Hit.Position,(rayDirection * SHADOW_RAY_LENGTH),v1)
- local characterRay = workspace:Raycast(Character.HumanoidRootPart.Position,Vector3.new(0,-180,0),v1)
- --Checks to See If Each Ray Hit
- if not shadowRay or not checkMouseRay or not characterRay then return end
- --Checks to See If The Distance Is Less Than The Max_Mouse_Distance
- if not ((shadowRay.Position - checkMouseRay.Position).Magnitude <= MAX_MOUSE_DISTANCE) then return end
- --Returns the Positions of The Rays
- return {characterRay.Position, Mouse.Hit.Position}
- end
- --Activates When Tool Is Left Clicked
- script.Parent.Activated:Connect(function()
- --Runs The Function
- local rayed = checkRays()
- --Checks To See If Anything Was Returned
- if not rayed then return end
- --Fires The RemoteEvent
- shadowEvent:FireServer(unpack(rayed))
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement