Advertisement
SxScripting

RogueWraith LocalScript

Aug 5th, 2021
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. --Constants
  2. local SHADOW_RAY_LENGTH = 40
  3. local MAX_MOUSE_DISTANCE = 150
  4. --Waits until Character is Loaded
  5. repeat wait() until game.Players.LocalPlayer.Character
  6. --Variables
  7. local Player = game.Players.LocalPlayer
  8. local Character = Player.Character
  9. local rayDirection = game.Lighting:GetSunDirection() --Gets where the Sun is at
  10. local Mouse = Player:GetMouse()
  11. --Remote Events
  12. local shadowEvent = game.ReplicatedStorage.Events:WaitForChild("RougeShadow")
  13. --Function to Check If You Can Teleport
  14. local function checkRays()
  15. --Filter to Exclude The Player's Character From Ray
  16. local v1 = RaycastParams.new()
  17. v1.FilterDescendantsInstances = {Character}
  18. v1.FilterType = Enum.RaycastFilterType.Blacklist
  19. --Making a Ray to See if Anything Hits
  20. local shadowRay = workspace:Raycast(Character.HumanoidRootPart.Position,(rayDirection * SHADOW_RAY_LENGTH),v1)
  21. local checkMouseRay = workspace:Raycast(Mouse.Hit.Position,(rayDirection * SHADOW_RAY_LENGTH),v1)
  22. local characterRay = workspace:Raycast(Character.HumanoidRootPart.Position,Vector3.new(0,-180,0),v1)
  23. --Checks to See If Each Ray Hit
  24. if not shadowRay or not checkMouseRay or not characterRay then return end
  25. --Checks to See If The Distance Is Less Than The Max_Mouse_Distance
  26. if not ((shadowRay.Position - checkMouseRay.Position).Magnitude <= MAX_MOUSE_DISTANCE) then return end
  27. --Returns the Positions of The Rays
  28. return {characterRay.Position, Mouse.Hit.Position}
  29.  
  30. end
  31. --Activates When Tool Is Left Clicked
  32. script.Parent.Activated:Connect(function()
  33. --Runs The Function
  34. local rayed = checkRays()
  35. --Checks To See If Anything Was Returned
  36. if not rayed then return end
  37. --Fires The RemoteEvent
  38. shadowEvent:FireServer(unpack(rayed))
  39. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement