EmeraldIT

....

Jul 7th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. local RunService = game:GetService("RunService")
  2. local players = game:GetService("Players")
  3.  
  4. local platform = workspace.MagicDisc
  5. local raycastDistance = 5
  6. local previousPosition = platform.Position
  7.  
  8. RunService.Heartbeat:Connect(function(dt)
  9. local currentPosition = platform.Position
  10. local platformVelocity = (currentPosition - previousPosition) / dt
  11. previousPosition = currentPosition
  12.  
  13. for _, player in pairs(players:GetPlayers()) do
  14. local character = player.Character
  15. if character and character:FindFirstChild("HumanoidRootPart") then
  16. local hrp = character.HumanoidRootPart
  17.  
  18. -- Raycast to check if the player is on the platform
  19. local rayOrigin = hrp.Position
  20. local rayDirection = Vector3.new(0, -raycastDistance, 0)
  21.  
  22. local raycastParams = RaycastParams.new()
  23. raycastParams.FilterDescendantsInstances = {character}
  24. raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
  25.  
  26. local result = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
  27.  
  28. if result and result.Instance and result.Instance:IsDescendantOf(platform) then
  29. -- Add the full platform velocity (X, Y, Z)
  30. hrp.AssemblyLinearVelocity += platformVelocity
  31. end
  32. end
  33. end
  34. end)
Advertisement
Add Comment
Please, Sign In to add comment