Players isn't spinning with the platform

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to create a spinning platform and when the player stand on it they move with the platform
  2. What is the issue? Include screenshots / videos if possible!
    the platform is spinning but when the player is on the platform it won’t move with the platform
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

heres my code

 
while task.wait()  do
	script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0.03,0)
end

3 Likes

To make the player move with the spinning platform, you need to make sure that the player’s HumanoidRootPart is welded to the platform when they touch it, and then unwelded when they leave.

local platform = script.Parent
local weld

local function onPartTouch(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
    if humanoid then
        weld = Instance.new('WeldConstraint')
        weld.Part0 = platform
        weld.Part1 = otherPart
        weld.Parent = platform
    end
end

local function onPartLeave(otherPart)
    if weld and weld.Part1 == otherPart then
        weld:Destroy()
        weld = nil
    end
end

platform.Touched:Connect(onPartTouch)
platform.TouchEnded:Connect(onPartLeave)

while true do
    platform.CFrame = platform.CFrame * CFrame.fromEulerAnglesXYZ(0,0.03,0)
    task.wait()
end

This script will create a new WeldConstraint between the platform and the player’s HumanoidRootPart whenever the player touches the platform, making the player move with the platform. When the player leaves the platform, the WeldConstraint is destroyed, allowing the player to move independently again.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.