I am trying to have an elevator move players down, where it then stops and falls down (a jumpscare, an elevator failure).
When the elevator is moving down steadily before it stops, as you would expect a regular elevator to, but the elevator jitters while moving and I don’t know why it is doing so. The elevator starts off moving normally, however it jitters and can make the player move in unintended ways.
Nothing I found accurately helped me with my issue, as I would like to use TweenService still and have it not jitter.
Code:
if APlayers.Value == 1 then
prompt.Enabled = false
for _,b in pairs(game.Workspace["Elevator House"].Barriers:GetChildren()) do
b.CanCollide = true
end
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPrimaryPartCFrame()
CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
model:SetPrimaryPartCFrame(CFrameValue.Value)
end)
local tween = tweenService:Create(CFrameValue, info, {Value = CFrameValue.Value - Vector3.new(0, 20, 0)})
local tween2 = tweenService:Create(CFrameValue, info2, {Value = CFrameValue.Value - Vector3.new(0, 60, 0)})
tween:Play()
tween.Completed:Connect(function()
model.Center.Sound:Play()
task.wait(8)
model.Center.Sound2:Play()
tween2:Play()
event:FireAllClients(player)
task.wait(1)
-- do tp stuff here within 3 seconds, this part is irrelevant to the tween stuff as it happens after the tweens
for _,v in pairs(players:GetChildren()) do
local char = v.Character
if char then
local humanrootpart = char.HumanoidRootPart
if humanrootpart then
task.wait(2.238)
local x = tppart.Position.X + math.random(-tppart.Size.X/2,tppart.Size.X/2)
local y = tppart.Position.Y + math.random(-tppart.Size.Y/2,tppart.Size.Y/2)
local z = tppart.Position.Z + math.random(-tppart.Size.Z/2,tppart.Size.Z/2)
humanrootpart.Position = Vector3.new(x,y,z)
end
end
end
--end of irrelevance
tween2.Completed:Connect(function()
CFrameValue:Destroy()
end)
end)
elseif game:GetService("ServerStorage").Check.Value == 1 then
game:GetService("ReplicatedStorage").ShowNotification:FireClient(player, "All players must be on the elevator!", 4)
else
game:GetService("ReplicatedStorage").ShowNotification:FireClient(player, "Seems the power isn't working. There should be a generator somewhere.", 4)
end
I’m not the most experienced scripter, and I don’t know if the script I have to move the whole model at once is the best to use here. It uses the primary part to move the entire model.