First of all, the event is called MouseClick - not "mouseClick". You're gonna have to match the case.
Secondly, the SetPrimaryPartCFrame function directly sets the model's CFrame - you're providing a fixed CFrame expecting it to increment the CFrame of the model. That is not how this function works, but you may look into the TranslateBy function - which is similar.
In order to effectively "increment" the CFrame of the model, you need to reference it's current CFrame using the GetPrimaryPartCFrame function, and then multiply by an offset CFrame.
local elevator = script.Parent.Parent.elevatorfloor
local movingparts = script.Parent.Parent.movingparts
script.Parent.ClickDetector.MouseClick:connect(function()
if elevatorfloor.Position.Y == 0.7 then
repeat
local current = movingparts:GetPrimaryPartCFrame()
local offset = CFrame.new(0,1,0)
movingparts:SetPrimaryPartCFrame(current*offset)
wait(0.1)
until
elevatorfloor.Position.Y >= 25.7
end
end)
If this still doesn't work, it means the if statement on line 6 is getting in the way or the elevatorfloor's Position is already greater than 25.7
3 comments
i tried your script and i got this
You have to set the PrimaryPart of your
movingpartsmodel prior to using the SetPrimaryPartCFrame function, because the function positions the model according to the PrimaryPart's location.