hi there, I need to find out how to make humanoid also float with moving part. as of right now the humanoid seems to be drowned in the moving part when this part moves up and down using below code.
local player = game.Players.LocalPlayer local part = workspace.Part part.Touched:Connect(function() player.Character:SetPrimaryPartCFrame(player.Character.HumanoidRootPart.CFrame + (part.CFrame.LookVector * Vector3.new(0.05, 0, 0))) end) local brick=script.Parent while wait(1) do for I=1,5 do brick.CFrame=brick.CFrame+Vector3.new(0,5,0) wait(2) end wait(1) for I=1,5 do brick.CFrame=brick.CFrame+Vector3.new(0,-0.2,0) wait() end end
any idea of how to make humanoid can stand on the moving part when it moved up?
Moving parts that interact with the player is complicated. Right now your animation for the brick looks fine, but when a player is standing on it, it teleports right through. This is because, according to the physics engine, the brick still isn't moving. To actually move it you use a BodyPosition.
A BodyPosition and similar objects tell the physics engine what to do. In this case, it makes the brick glide to a position in space, which is what you want. It can be applied like this:
local brick = script.Parent local bodyPosition = Instance.new("BodyPosition",brick) while true do bodyPosition.Position = brick.Position+Vector3.new(0,25,0) --This position should be the FINAL destination of the UP movement wait(2) --Wait for the up movement to finish bodyPosition.Position = brick.Position+Vector3.new(0,-25,0) --This position should be the FINAL destination of the DOWN movement wait(2) --Wait for the down movement to finish end
Make sure that the brick is NOT anchored. Also, If the part isn't moving, the MaxForce of the bodyPosition might be too low. You can replace it by going
bodyPosition.MaxForce = Vector3.new(10000,10000,10000) --10000 is just an example number, you can tinker with it
If the brick goes to far and rubberbands back, the D ("dampening") is too low. Set it higher by going
bodyPosition.D = 3000 --3000 is just an example number
Feel free to tinker with these numbers to get the effect you want. For further reading you can use this on the wiki