Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RunService = game:GetService("RunService")
- local players = game:GetService("Players")
- local platform = workspace.MagicDisc
- local raycastDistance = 5
- local previousPosition = platform.Position
- RunService.Heartbeat:Connect(function(dt)
- local currentPosition = platform.Position
- local platformVelocity = (currentPosition - previousPosition) / dt
- previousPosition = currentPosition
- for _, player in pairs(players:GetPlayers()) do
- local character = player.Character
- if character and character:FindFirstChild("HumanoidRootPart") then
- local hrp = character.HumanoidRootPart
- -- Raycast to check if the player is on the platform
- local rayOrigin = hrp.Position
- local rayDirection = Vector3.new(0, -raycastDistance, 0)
- local raycastParams = RaycastParams.new()
- raycastParams.FilterDescendantsInstances = {character}
- raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
- local result = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
- if result and result.Instance and result.Instance:IsDescendantOf(platform) then
- -- Add the full platform velocity (X, Y, Z)
- hrp.AssemblyLinearVelocity += platformVelocity
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment