Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I change the position of an instance?

Asked by 1 year ago
if locale == true and p2m == false then
            if pFolder:FindFirstChild("Portal1") == nil then
                print("Made 1")
                Portal1.Parent = pFolder
                Portal1.Position = previous
            else
                print("Remade 1")
                Portal1.Position = previous
            end
        elseif locale == true and p2m == true then
            if pFolder:FindFirstChild("Portal2") == nil then
                print("Made 2")
                Portal2.Parent = pFolder
                Portal2.Position = previous
            else
                print("Remade 2")
                Portal2.Position = previous
            end
        elseif p2m == true and p3m == true then
            if pFolder:FindFirstChild("Portal3") == nil then
                print("Made 3")
                Portal3.Parent = pFolder
                Portal3.Position = previous
            else
                print("Remade 4")
                Portal3.Position = previous
            end

I'm trying to make it so that the player can place up to three portals by pressing Z. If they press Z again after making three portals, it'd move the first portal, then the second, and so on. However, it just refuses to move them. They all work the first time around, but they never get moved.

This is the LocalScript's code.

if portal1made == false then
                        print("First Portal Made!")
                        globalCD = false
                        portal1made = true
                        portal2made = false
                        portal1 = Player.Character.Torso.Position
                        Player.Character.Humanoid.WalkSpeed = 0
                        task.wait(.2)
                        slam:Play()
                        Remote:FireServer("Create", rightArm.Position, rightArm.Rotation, portal1, portal1made, portal2made, portal3made)
                        task.wait(2)
                        Player.Character.Humanoid.WalkSpeed = 16
                        task.wait(3)
                        globalCD = true
                    elseif portal1made == true and portal2made == false then
                        print("Second Portal Made!")
                        globalCD = false
                        portal2made = true
                        portal3made = false
                        portal2 = Player.Character.Torso.Position
                        Player.Character.Humanoid.WalkSpeed = 0
                        task.wait(.2)
                        slam:Play()
                        Remote:FireServer("Create", rightArm.Position, rightArm.Rotation, portal2, portal1made, portal2made, portal3made)
                        task.wait(2)
                        Player.Character.Humanoid.WalkSpeed = 16
                        task.wait(3)
                        globalCD = true
                    elseif portal2made == true and portal3made == false then
                        print("Third Portal Made!")
                        globalCD = false
                        portal3made = true
                        portal1made = false
                        portal3 = Player.Character.Torso.Position
                        Player.Character.Humanoid.WalkSpeed = 0
                        task.wait(.2)
                        slam:Play()
                        Remote:FireServer("Create", rightArm.Position, rightArm.Rotation, portal3, portal1made, portal2made, portal3made)
                        task.wait(2)
                        Player.Character.Humanoid.WalkSpeed = 16
                        task.wait(3)
                        globalCD = true
                    end

"Previous" refers to "portal1", "portal2", and "portal3", all of which refer to,

local portal1 = nil
local portal2 = nil
local portal3 = nil

These change to the player's current position every time they press z, and by themselves work just fine, with positions being changed on the fourth use as they should. Additionally, when printing "previous" on the fourth use, it does print the new location, so that's not the issue. The objects simply won't move.

Answer this question