Hello, I am making a moving platform, but when the part moves, the player that's on it doesn't move Can You Help Me Fix That?

So… I want to make this moving platform that moves the player that’s on it, but the player stays on the same location as I mentioned in the title.
Here’s a video with what happens
why_is_this_happening.wmv (517.8 KB)
(Sorry for the bad video quality)
so… thats the script I put into the moving part:

while true do
wait()
for i= 1, 50 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0,-2)
wait()
end
for i= 1, 50 do
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0,0,2)
wait()
end
end

Before posting here be sure to check other sources or just try using google

1 Like

Thanks so much man, I am new to the devforum

1 Like

A good way to approach a problem like this is to:

  • Weld each of he parts of the player in contact with the platform to the platform

You could accomplish something like this in the following way:


In a normal, server-side script:

-- Fires this code whenever the platform comes into contact with another part
game.Workspace.Platform.Touched:Connect(function(partTouched)
    -- Creates a new WeldConstraint
    local wd = Instance.new("WeldConstraint")
    -- Parents the constraint to the workspace
    wd.Parent = game.Workspace
    -- Connects the weld between the platform and the part that touched it
    wd.Part0 = game.Workspace.Platform
    wd.Part1 = partTouched
end)

Hope this helps.

Won’t that make the player unable to move or if the player moves the part will also move?
I am kind of new to scripting so I’m not sure

1 Like

It will make the player unable to move. I’m assuming that OP has extra variables to account for in their code (Humanoid.WalkSpeed for instance), but both will move if the part (or player’s) CFrame is updated.

1 Like