so im trying to make an elevator script to work an elevator, but its not working at all and when i click the button the elevator just disappears.and it gives me no error messages. am i doing something wrong?
hers the script: (its a normal script)
--256.6
print('entrance_elevator_controll:script active')
local up_butt = workspace.entrance_elevator_controll_ent.top_butt
local down_butt = workspace.entrance_elevator_controll_ent.bottom_butt
local top = workspace.entrance_elevator_controll_ent.top_com
local bottom = workspace.entrance_elevator_controll_ent.bottom_com
local canup = false
local candown = true
local Part = workspace.entrance_elevator_ent -- this is the Part we will move
local newPos = Part.Position + Vector3.new(0,0,0) -- the position the Part will go to
local Time = 20 -- the time that the script will take to move the part
local Increment = 0.5 -- the Part will move 0.5 studs each time it moves
local Debounce = false
local Diff = newPos - Part.Position -- the difference between the two positions
local Mag = Diff.magnitude -- the distance between the two parts
local Direction = CFrame.new(Part.Position, newPos).lookVector
function MovePart() -- function to move the Part
if Debounce then end -- end the function if debounce is true
Debounce = true -- make Debounce true so the function can't run
for n = 0, Mag, Increment do
Part.CFrame = Part.CFrame + (Direction * Increment)
wait( (Time/Mag) * Increment )
end
end
up_butt.ClickDetector.MouseClick:Connect(function()
if canup == true then
newPos = Part.Position + Vector3.new(0,60,0)
up_butt.Material = 'Neon'
MovePart()
up_butt.ClickDetector.MaxActivationDistance = 0
bottom.Material = 'SmoothPlastic'
wait(Time)
canup = false
candown = true
down_butt.ClickDetector.MaxActivationDistance = 35
up_butt.Material = 'SmoothPlastic'
top.Material = 'Neon'
end
end)
down_butt.ClickDetector.MouseClick:Connect(function()
if candown == true then
newPos = Part.Position + Vector3.new(0,-60,0)
down_butt.Material = 'Neon'
MovePart()
down_butt.ClickDetector.MaxActivationDistance = 0
top.Material = 'SmoothPlastic'
wait(Time)
candown = false
canup = true
down_butt.ClickDetector.MaxActivationDistance = 35
down_butt.Material = 'SmoothPlastic'
bottom.Material = 'Neon'
end
end)
