generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Lerp not working or is the script wrong?

Previous Thread :: Next Thread 
i_Movie is not online. i_Movie
Joined: 06 Apr 2014
Total Posts: 11725
20 Jul 2016 06:26 PM
local Door = workspace:FindFirstChild("LerpDoor")

local Pos = Vector3.new(-53.315, 24.37, -157.299)
local Pos2 = Vector3.new(-53.315, 50.63, -157.299)

local EndPos = Vector3.new(-53.315, 50.63, -157.299)
local EndPos2 = Vector3.new(-53.315, 24.37, -157.299)

MainEntrance.MouseButton1Down:connect(function()
if MainEntrance.Text == "Closed" then
MainEntrance.Text = "Open"
C.Text = "Curtain: Open"
MainEntrance.BackgroundColor3 = Color3.new(0,85,0)
for ratio1 = 0,1,0.01 do
local NewPos = Pos:lerp(EndPos, ratio1)
Door.Position = NewPos
wait()
end
elseif MainEntrance.Text == "Open" then
MainEntrance.Text = "Closed"
C.Text = "Curtain: Closed"
MainEntrance.BackgroundColor3 = Color3.new(170,0,0)
for ratio2 = 0,1,0.01 do
local NewPos = Pos2:lerp(EndPos2, ratio2)
Door.Position = NewPos
wait()
end
end
end)


12,014
Report Abuse
MisunderstoodOwl is not online. MisunderstoodOwl
Joined: 04 Oct 2014
Total Posts: 181
20 Jul 2016 06:50 PM
Is anything happening? Any errors?
Report Abuse
i_Movie is not online. i_Movie
Joined: 06 Apr 2014
Total Posts: 11725
20 Jul 2016 06:52 PM
Checked output, nothing.. :/


11,802
Report Abuse
MisunderstoodOwl is not online. MisunderstoodOwl
Joined: 04 Oct 2014
Total Posts: 181
20 Jul 2016 06:59 PM
Are the texts of your guis changing?
Report Abuse
i_Movie is not online. i_Movie
Joined: 06 Apr 2014
Total Posts: 11725
20 Jul 2016 07:00 PM
Yup


11,802
Report Abuse
MisunderstoodOwl is not online. MisunderstoodOwl
Joined: 04 Oct 2014
Total Posts: 181
20 Jul 2016 07:14 PM
Lol nevermind I know what's wrong. Just use this.


local Door = workspace:FindFirstChild("LerpDoor")

local Pos = Vector3.new(-53.315, 24.37, -157.299)
local EndPos = Vector3.new(-53.315, 50.63, -157.299)
local steps = 100
local dif = (Pos-EndPos)/steps
Door.Position = pos


MainEntrance.MouseButton1Down:connect(function()
if MainEntrance.Text == "Closed" then
MainEntrance.Text = "Open"
C.Text = "Curtain: Open"
MainEntrance.BackgroundColor3 = Color3.new(0,85,0)
for ratio1 = 0,1,(1/steps) do
Door.CFrame = Door.CFrame * CFrame.new(-dif)
wait()
end
elseif MainEntrance.Text == "Open" then
MainEntrance.Text = "Closed"
C.Text = "Curtain: Closed"
MainEntrance.BackgroundColor3 = Color3.new(170,0,0)
for ratio2 = 0,1,(1/steps) do
Door.CFrame = Door.CFrame * CFrame.new(dif)
wait()
end
end
end)


Report Abuse
MisunderstoodOwl is not online. MisunderstoodOwl
Joined: 04 Oct 2014
Total Posts: 181
20 Jul 2016 07:15 PM
Err did that backwards; this is better



local Door = workspace:FindFirstChild("LerpDoor")

local Pos = Vector3.new(-53.315, 24.37, -157.299)
local EndPos = Vector3.new(-53.315, 50.63, -157.299)
local steps = 100
local dif = (Pos-EndPos)/steps
Door.Position = pos


MainEntrance.MouseButton1Down:connect(function()
if MainEntrance.Text == "Closed" then
MainEntrance.Text = "Open"
C.Text = "Curtain: Open"
MainEntrance.BackgroundColor3 = Color3.new(0,85,0)
for ratio1 = 0,1,(1/steps) do
Door.CFrame = Door.CFrame * CFrame.new(dif)
wait()
end
elseif MainEntrance.Text == "Open" then
MainEntrance.Text = "Closed"
C.Text = "Curtain: Closed"
MainEntrance.BackgroundColor3 = Color3.new(170,0,0)
for ratio2 = 0,1,(1/steps) do
Door.CFrame = Door.CFrame * CFrame.new(-dif)
wait()
end
end
end)
Report Abuse
i_Movie is not online. i_Movie
Joined: 06 Apr 2014
Total Posts: 11725
20 Jul 2016 07:46 PM
Thank you!


11,768
Report Abuse
i_Movie is not online. i_Movie
Joined: 06 Apr 2014
Total Posts: 11725
20 Jul 2016 07:55 PM
Doesn't work.. :/ Still no output, should it be a serverscript or a localscript? Because here's the full script.

local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Gui = PlayerGui:WaitForChild("SurfaceGui")
local ControlFrame = Gui:FindFirstChild("ControlFrame")
local DoorHandler = ControlFrame:FindFirstChild("DoorHandler")
local MainEntrance = DoorHandler:FindFirstChild("Curtain")
local C = DoorHandler:FindFirstChild("C")

local Door = workspace:FindFirstChild("LerpDoor")

local Pos = Vector3.new(-53.315, 24.37, -157.299)
local EndPos = Vector3.new(-53.315, 50.63, -157.299)
local steps = 100
local dif = (Pos-EndPos)/steps
Door.Position = pos


MainEntrance.MouseButton1Down:connect(function()
if MainEntrance.Text == "Closed" then
MainEntrance.Text = "Open"
C.Text = "Curtain: Open"
MainEntrance.BackgroundColor3 = Color3.new(0,85,0)
for ratio1 = 0,1,(1/steps) do
Door.CFrame = Door.CFrame * CFrame.new(dif)
wait()
end
elseif MainEntrance.Text == "Open" then
MainEntrance.Text = "Closed"
C.Text = "Curtain: Closed"
MainEntrance.BackgroundColor3 = Color3.new(170,0,0)
for ratio2 = 0,1,(1/steps) do
Door.CFrame = Door.CFrame * CFrame.new(-dif)
wait()
end
end
end)


11,783
Report Abuse
i_Movie is not online. i_Movie
Joined: 06 Apr 2014
Total Posts: 11725
20 Jul 2016 08:55 PM
bump


11,873
Report Abuse
MisunderstoodOwl is not online. MisunderstoodOwl
Joined: 04 Oct 2014
Total Posts: 181
20 Jul 2016 10:36 PM
Is the block anchored?
Report Abuse
i_Movie is not online. i_Movie
Joined: 06 Apr 2014
Total Posts: 11725
21 Jul 2016 12:31 AM
Yes, should it not be?


11,873
Report Abuse
antonio6643 is not online. antonio6643
Joined: 30 Aug 2009
Total Posts: 791
21 Jul 2016 12:38 AM
The problem is you're trying to lerp a position, when you should be lerping a CFrame.

Heres the updated code(Be aware I did not run this through studio's IDE):

local Door = workspace:FindFirstChild("LerpDoor")

local Pos = CFrame.new(-53.315, 24.37, -157.299)
local Pos2 = CFrame.new(-53.315, 50.63, -157.299)

local EndPos = CFrame.new(-53.315, 50.63, -157.299)
local EndPos2 = CFrame.new(-53.315, 24.37, -157.299)

MainEntrance.MouseButton1Down:connect(function()
if MainEntrance.Text == "Closed" then
MainEntrance.Text = "Open"
C.Text = "Curtain: Open"
MainEntrance.BackgroundColor3 = Color3.new(0,85,0)
for ratio1 = 0,1,0.01 do
Door.CFrame = Door.CFrame:lerp(EndPos, ratio1)
wait()
end
elseif MainEntrance.Text == "Open" then
MainEntrance.Text = "Closed"
C.Text = "Curtain: Closed"
MainEntrance.BackgroundColor3 = Color3.new(170,0,0)
for ratio2 = 0,1,0.01 do
Door.CFrame = Door.CFrame:lerp(EndPos2, ratio2)
wait()
end
end
end)


You're gonna wanna make sure that the CFrame values are correct, because they're probably not.


--Your friendly neighborhood programmer--
Report Abuse
i_Movie is not online. i_Movie
Joined: 06 Apr 2014
Total Posts: 11725
21 Jul 2016 01:01 AM
Oh, thanks! I'll test it


11,873
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image