Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make my for loop move my elevator part up?

local ElevatorPlade = script.Parent
local function VirkendeElevator()
	if ElevatorPlade.Parent:FindFirstChild("DarkBrotherhood4") then
		wait(2)
		ElevatorPlade.BrickColor = BrickColor.new("Really red")
		for Y = 1, 20, 1 do
			ElevatorPlade.Position = Vector3.new(-41.25, Y, -82.875)
		end
	end
end
      


ElevatorPlade.Touched:Connect(VirkendeElevator())

I wanted the Elevator part to move up 20 times like if it was an elevator but when I step on the part it just says "attempt to call a nil value"

9 comments

0

Uhm, what are you trying to do at Line 03? Why would you search for your name?

0

Did you wanted the part to move 20 times slowly or instantly?

0

i was experimenting with the FindFirstChild function usually i would put Humanoid instead of my own name

0

Dark, does it work now?

0

Line 03 is fine but it's not really specific but it's fine, it would still work, Line 14 is your mistake, You should remove Open and Close Parentheses

0

Yeah..

0

to make your Elevator only goes up, you'd only need to update its Position Y, unless you kind of flipped the brick or something

0

its something to do with the for loop and position part cause the part does turn red but it doesnt move at all

0

I'll post it in a sec

1 answer

✓ Accepted answer

EDIT: Lemme just point out the possible bug/error in your code

The Open and Close Parentheses :>

Touched:Connect(VirkendeElevator())

This is not really necessary but if you'll create a multiplayer game with many peeps trying to interact with the elevator if ElevatorPlade.Parent:FindFirstChild("DarkBrotherhood4") then

Uhm Static X and Z is fine but not really recommended, The Y is explained at code block. It would work if your Elevator Plate is at exactly Position-Y = 0 , ElevatorPlade.Position = Vector3.new(-41.25, Y, -82.875)

local ElevatorPlade = script.Parent
local function VirkendeElevator()
    if ElevatorPlade.Parent:FindFirstChild("DarkBrotherhood4") then 
        wait(2)
        ElevatorPlade.BrickColor = BrickColor.new("Really red")
        for Y = 1, 20, 1 do --Let's just say this is only a counter
            ElevatorPlade.Position = Vector3.new(ElevatorPlade.Position.X, ElevatorPlade.Position.Y+1, ElevatorPlade.Position.Z) 
--Y+1 entirely depends to you of how much will you increment its position, Too much will cause the player to miss the platform
        end
    end
end



ElevatorPlade.Touched:Connect(VirkendeElevator)

EDIT: Didn't mean to be harsh, Sorry :>

3 comments

0

haha it works but is there a way to make for loops go slower inbetween the increments? Do i just put a wait?

0

Oh yes, Put wait inside the For Loop :> or you could just make Y increment by 0.1

0

The third digit in a for loop is the increment the lower it is the smoother it will be https://developer.roblox.com/en-us/articles/Roblox-Coding-Basics-Loops

This discussion is preserved as it was. New answers, comments, and votes are closed.