In the while loop, (Which is the part when the platform spins fast), I want the player to be thrown off of it if the player steps on it. How would I achieve this?
while true do
wait(3)
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,2.5,0)
wait(.01)
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,2.5,0)
wait(.01)
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,2.5,0)
wait(.01)
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,2.5,0)
wait(.8)
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,2.5,0)
wait(.01)
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,2.5,0)
wait(.01)
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,2.5,0)
wait(.01)
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,2.5,0)
wait(.8)
local Num = 12
while Num >= 0 do
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,25,0)
wait(0.00000000000000001)
Num-= 1
end
end
while Num >= 0 do
script.Parent.Orientation = script.Parent.Orientation+ Vector3.new(0,25,0)
wait(0.00000000000000001)
Num-= 1
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.HumanoidRootPart.Velocity = script.Parent.CFrame.LookVector * 100
end
end)
end
Nothing but lag happens. The player glitches around when it tries to move.
local Part = script.Parent
for i = 1, 7 do
Part.Orientation += Vector3.new(2.5)
end
Use task.wait()
That is very bad, you should not use connections in while loops.
Use AssemblyLinearVelocity, Velocity is deprecated.
Also, I assume you want to fling them upwards and forwards so you should also use UpVector
for i = Num, 0, -1 do -- This means : Start at Num, go to 0, with a step of -1
task.wait()
Part.Orientation += Vector3.new(0,25,0)
for _, Touching in workspace:GetPartsInPart(Part) do
if game.Players:GetPlayerFromCharacter(Touching.Parent) then
Touching.Parent.HumanoidRootPart.AssemblyLinearVelocity = (Part.CFrame.UpVector * 100) + (Part.CFrame.LookVector * 100)
end
end
end