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

Script that's meant to make then move multiple parts gets moved by other players?

Asked by 1 year ago

It's pretty rare to get an answer here so I won't hold my breath, but if anyone can help me figure this out, I'm making a small game based on having a bunch of teleportation abilities that are required to progress through puzzles. A really big issue, however, is that if two players use Portal Creation, after the first three portals are made, other players will move those three portals instead of making their own.

elseif locale == true and p2m == true then
            if pFolder:FindFirstChild("Portal2") == nil then
                if prisma == true then
                    Portal2 = ServerStorage.prismPortal:Clone()
                    Portal2.Name = "Portal2"
                elseif prisma2 == true then
                    Portal2 = ServerStorage.darkPortal:Clone()
                    Portal2.Name = "Portal2"
                elseif prisma == false and prisma2 == false then
                    Portal2 = ServerStorage.Portal:Clone()
                    Portal2.Name = "Portal2"
                end
                print("Made 2", previous)
                Portal2:Clone()
                Portal2.Parent = pFolder
                Portal2.Position = previous + Vector3.new(0,-2,0)
            else
                print("Remade 2", previous)
                pFolder:FindFirstChild("Portal2").Position = previous + Vector3.new(0,-2,0)
            end
        elseif p2m == true and p3m == true then
            if pFolder:FindFirstChild("Portal3") == nil then
                if prisma == true then
                    Portal3 = ServerStorage.prismPortal:Clone()
                    Portal3.Name = "Portal3"
                elseif prisma2 == true then
                    Portal3 = ServerStorage.darkPortal:Clone()
                    Portal3.Name = "Portal3"
                elseif prisma == false and prisma2 == false then
                    Portal3 = ServerStorage.Portal:Clone()
                    Portal3.Name = "Portal3"
                end
                Portal3:Clone()
                Portal3.Position = previous + Vector3.new(0,-2,0)
                Portal3.Parent = pFolder
            else
                print("Remade 3", previous)
                pFolder:FindFirstChild("Portal3").Position = previous + Vector3.new(0,-2,0)
            end
        end
        local rArm = Player.Character:FindFirstChild("Right Arm")
        pOrb.Parent = rArm
        weld.Parent = rArm
        weld.Part0 = rArm
        weld.Part1 = pOrb
        pOrb.Position = transport
        -- print("RAP:", transport)
        -- print("RAR:", detected)
        -- print("TAP:", previous)
        task.wait(.12)
        p1.Enabled = true
        p2.Enabled = true
        p3.Enabled = true
        p4.Enabled = true
        task.wait(.12)
        p1.Enabled = false
        p2.Enabled = false
        p3.Enabled = false
        p4.Enabled = false

Some notes, locale, p2m, p3m, prisma, and prisma2 are all remotes from the local script.

Prisma and Prisma2 are mostly irrelevant, they're just cosmetic versions of the ability that make different portals. locale, p2m, and p3m all refer to boolean values in the local script that are used to determine which portals the player has made.

Here's the local script portion, incase it can be of help for helping me figure out why this issue is happening.

if InputObject.KeyCode == Enum.KeyCode.Z then
                -- print("Portal Made!")
                if globalCD == true then
                    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, prisma1, prisma2)
                        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, prisma1, prisma2)
                        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, prisma1)
                        task.wait(2)
                        Player.Character.Humanoid.WalkSpeed = 16
                        task.wait(3)
                        globalCD = true
                    end
                elseif globalCD == false then
                    warn("On Cooldown!")
                end
0
Kinda confused on where the variables are coming from, it might be a error with them. Jay123abc2 241 — 1y

Answer this question