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

Why is my local parts script not working correctly?

Asked by 9 years ago

I have used local parts before, and they worked fine. I used the same scripting and changed the part's CFrame. It doesn't put the parts where I want them to go. I don't know why this is but I hope you do. Here is the script:

Permission = {"UndiscoveredLimited","Idontcare2004","moonmim","Amy21227","funkstaducksta"}
Player = game.Players.LocalPlayer

Bin = Instance.new("Camera",game.Workspace)
Bin.Name = "LocalBin"

function check(plr)
    for i = 1,#Permission do
        if plr.Name == Permission[i] then
            return true
        end
    end
    return false
end

check(Player)

if check == true then
    Part1 = Instance.new("Part",Bin)
    Part1.BrickColor = BrickColor.new("Medium blue")
    Part1.Anchored = true
    Part1.FormFactor = "Custom"
    Part1.Size = Vector3.new(5,8,1)
    Part1.CFrame = CFrame.new(-135.352,17.99,-76.623)*CFrame.Angles(-180,-79.999,-180)
    Part1.BackSurface = "Smooth"
    Part1.BottomSurface = "Smooth"
    Part1.FrontSurface = "Smooth"
    Part1.LeftSurface = "Smooth"
    Part1.RightSurface = "Smooth"
    Part1.TopSurface = "Smooth"
    Part2 = Instance.new("Part",Bin)
    Part2.BrickColor = BrickColor.new("Medium blue")
    Part2.Anchored = true
    Part2.FormFactor = "Custom"
    Part2.Size = Vector3.new(5,8,1)
    Part2.CFrame = CFrame.new(-135.352,17.99,-71.872)*CFrame.Angles(0,-80,0)
    Part2.BackSurface = "Smooth"
    Part2.BottomSurface = "Smooth"
    Part2.FrontSurface = "Smooth"
    Part2.LeftSurface = "Smooth"
    Part2.RightSurface = "Smooth"
    Part2.TopSurface = "Smooth"
    Part3 = Instance.new("WedgePart",Bin)
    Part3.BrickColor = BrickColor.new("Medium blue")
    Part3.Anchored = true
    Part3.FormFactor = "Custom"
    Part3.Size = Vector3.new(1,12,2)
    Part3.CFrame = CFrame.new(-135.091,7.99,-70.391)*CFrame.Angles(0,10.001,180)
    Part3.BackSurface = "Smooth"
    Part3.BottomSurface = "Smooth"
    Part3.FrontSurface = "Smooth"
    Part3.LeftSurface = "Smooth"
    Part3.RightSurface = "Smooth"
    Part3.TopSurface = "Smooth"
    Part4 = Instance.new("WedgePart",Bin)
    Part4.BrickColor = BrickColor.new("Medium blue")
    Part4.Anchored = true
    Part4.FormFactor = "Custom"
    Part4.Size = Vector3.new(1,1,5)
    Part4.CFrame = CFrame.new(-135.352,13.49,-71.869)*CFrame.Angles(0,10.001,180)
    Part4.BackSurface = "Smooth"
    Part4.BottomSurface = "Smooth"
    Part4.FrontSurface = "Smooth"
    Part4.LeftSurface = "Smooth"
    Part4.RightSurface = "Smooth"
    Part4.TopSurface = "Smooth"
    Part5 = Instance.new("WedgePart",Bin)
    Part5.BrickColor = BrickColor.new("Medium blue")
    Part5.Anchored = true
    Part5.FormFactor = "Custom"
    Part5.Size = Vector3.new(1,2,12)
    Part5.CFrame = CFrame.new(-135.092,7.99,-78.096)*CFrame.Angles(-90,-0,170)
    Part5.BackSurface = "Smooth"
    Part5.BottomSurface = "Smooth"
    Part5.FrontSurface = "Smooth"
    Part5.LeftSurface = "Smooth"
    Part5.RightSurface = "Smooth"
    Part5.TopSurface = "Smooth"
    Part6 = Instance.new("WedgePart",Bin)
    Part6.BrickColor = BrickColor.new("Medium blue")
    Part6.Anchored = true
    Part6.FormFactor = "Custom"
    Part6.Size = Vector3.new(1,5,1)
    Part6.CFrame = CFrame.new(-135.352,13.49,-76.619)*CFrame.Angles(-90,-0,170)
    Part6.BackSurface = "Smooth"
    Part6.BottomSurface = "Smooth"
    Part6.FrontSurface = "Smooth"
    Part6.LeftSurface = "Smooth"
    Part6.RightSurface = "Smooth"
    Part6.TopSurface = "Smooth"
else
    Part1 = Instance.new("Part",Bin)
    Part1.BrickColor = BrickColor.new("Medium blue")
    Part1.Anchored = true
    Part1.FormFactor = "Custom"
    Part1.Size = Vector3.new(5,20,1)
    Part1.CFrame = CFrame.new(-135.352,11.99,-76.623)*CFrame.Angles(-180,-79.999,-180)
    Part1.BackSurface = "Smooth"
    Part1.BottomSurface = "Smooth"
    Part1.FrontSurface = "Smooth"
    Part1.LeftSurface = "Smooth"
    Part1.RightSurface = "Smooth"
    Part1.TopSurface = "Smooth"
    Part2 = Instance.new("Part",Bin)
    Part2.BrickColor = BrickColor.new("Medium blue")
    Part2.Anchored = true
    Part2.FormFactor = "Custom"
    Part2.Size = Vector3.new(5,20,1)
    Part2.CFrame = CFrame.new(-135.352,11.99,-71.872)*CFrame.Angles(0,-80,0)
    Part2.BackSurface = "Smooth"
    Part2.BottomSurface = "Smooth"
    Part2.FrontSurface = "Smooth"
    Part2.LeftSurface = "Smooth"
    Part2.RightSurface = "Smooth"
    Part2.TopSurface = "Smooth"
end

1 answer

Log in to vote
0
Answered by 9 years ago

Firstly, you must use game.Workspace.CurrentCamera. You can't make a specific camera for holding local parts.

Secondly, you need to make a variable which includes the function in it, so that the if statement on line 18 works.

Also, I'd recommend using local variables for Part1, Part2, etc.

Permission = {"UndiscoveredLimited","Idontcare2004","moonmim","Amy21227","funkstaducksta"}
Player = game.Players.LocalPlayer

Bin = game.Workspace.CurrentCamera --Use the currentcamera, so that the parts show for the player.

function check(plr)
    for i = 1,#Permission do
        if plr.Name == Permission[i] then
            return true
        end
    end
    return false
end

local pCheck = check(Player) --Making a variable to hold the returned boolean of the function.

if pCheck == true then --Check if the function returns true.
    local Part1 = Instance.new("Part",Bin)
    Part1.BrickColor = BrickColor.new("Medium blue")
    Part1.Anchored = true
    Part1.FormFactor = "Custom"
    Part1.Size = Vector3.new(5,8,1)
    Part1.CFrame = CFrame.new(-135.352,17.99,-76.623)*CFrame.Angles(-180,-79.999,-180)
    Part1.BackSurface = "Smooth"
    Part1.BottomSurface = "Smooth"
    Part1.FrontSurface = "Smooth"
    Part1.LeftSurface = "Smooth"
    Part1.RightSurface = "Smooth"
    Part1.TopSurface = "Smooth"
    local Part2 = Instance.new("Part",Bin)
    Part2.BrickColor = BrickColor.new("Medium blue")
    Part2.Anchored = true
    Part2.FormFactor = "Custom"
    Part2.Size = Vector3.new(5,8,1)
    Part2.CFrame = CFrame.new(-135.352,17.99,-71.872)*CFrame.Angles(0,-80,0)
    Part2.BackSurface = "Smooth"
    Part2.BottomSurface = "Smooth"
    Part2.FrontSurface = "Smooth"
    Part2.LeftSurface = "Smooth"
    Part2.RightSurface = "Smooth"
    Part2.TopSurface = "Smooth"
    local Part3 = Instance.new("WedgePart",Bin)
    Part3.BrickColor = BrickColor.new("Medium blue")
    Part3.Anchored = true
    Part3.FormFactor = "Custom"
    Part3.Size = Vector3.new(1,12,2)
    Part3.CFrame = CFrame.new(-135.091,7.99,-70.391)*CFrame.Angles(0,10.001,180)
    Part3.BackSurface = "Smooth"
    Part3.BottomSurface = "Smooth"
    Part3.FrontSurface = "Smooth"
    Part3.LeftSurface = "Smooth"
    Part3.RightSurface = "Smooth"
    Part3.TopSurface = "Smooth"
    local Part4 = Instance.new("WedgePart",Bin)
    Part4.BrickColor = BrickColor.new("Medium blue")
    Part4.Anchored = true
    Part4.FormFactor = "Custom"
    Part4.Size = Vector3.new(1,1,5)
    Part4.CFrame = CFrame.new(-135.352,13.49,-71.869)*CFrame.Angles(0,10.001,180)
    Part4.BackSurface = "Smooth"
    Part4.BottomSurface = "Smooth"
    Part4.FrontSurface = "Smooth"
    Part4.LeftSurface = "Smooth"
    Part4.RightSurface = "Smooth"
    Part4.TopSurface = "Smooth"
    local Part5 = Instance.new("WedgePart",Bin)
    Part5.BrickColor = BrickColor.new("Medium blue")
    Part5.Anchored = true
    Part5.FormFactor = "Custom"
    Part5.Size = Vector3.new(1,2,12)
    Part5.CFrame = CFrame.new(-135.092,7.99,-78.096)*CFrame.Angles(-90,-0,170)
    Part5.BackSurface = "Smooth"
    Part5.BottomSurface = "Smooth"
    Part5.FrontSurface = "Smooth"
    Part5.LeftSurface = "Smooth"
    Part5.RightSurface = "Smooth"
    Part5.TopSurface = "Smooth"
    local Part6 = Instance.new("WedgePart",Bin)
    Part6.BrickColor = BrickColor.new("Medium blue")
    Part6.Anchored = true
    Part6.FormFactor = "Custom"
    Part6.Size = Vector3.new(1,5,1)
    Part6.CFrame = CFrame.new(-135.352,13.49,-76.619)*CFrame.Angles(-90,-0,170)
    Part6.BackSurface = "Smooth"
    Part6.BottomSurface = "Smooth"
    Part6.FrontSurface = "Smooth"
    Part6.LeftSurface = "Smooth"
    Part6.RightSurface = "Smooth"
    Part6.TopSurface = "Smooth"
else --Runs what happens if the function returns true
    local Part1 = Instance.new("Part",Bin)
    Part1.BrickColor = BrickColor.new("Medium blue")
    Part1.Anchored = true
    Part1.FormFactor = "Custom"
    Part1.Size = Vector3.new(5,20,1)
    Part1.CFrame = CFrame.new(-135.352,11.99,-76.623)*CFrame.Angles(-180,-79.999,-180)
    Part1.BackSurface = "Smooth"
    Part1.BottomSurface = "Smooth"
    Part1.FrontSurface = "Smooth"
    Part1.LeftSurface = "Smooth"
    Part1.RightSurface = "Smooth"
    Part1.TopSurface = "Smooth"
    local Part2 = Instance.new("Part",Bin)
    Part2.BrickColor = BrickColor.new("Medium blue")
    Part2.Anchored = true
    Part2.FormFactor = "Custom"
    Part2.Size = Vector3.new(5,20,1)
    Part2.CFrame = CFrame.new(-135.352,11.99,-71.872)*CFrame.Angles(0,-80,0)
    Part2.BackSurface = "Smooth"
    Part2.BottomSurface = "Smooth"
    Part2.FrontSurface = "Smooth"
    Part2.LeftSurface = "Smooth"
    Part2.RightSurface = "Smooth"
    Part2.TopSurface = "Smooth"
end
0
It doesn't work properly, it makes the brick go strange, check for yourself, I've added you to the script: http://www.roblox.com/Building-Place-place?id=166297081 General_Scripter 425 — 9y
0
It might be the way you've CFramed the bricks. Not too sure. Spongocardo 1991 — 9y
Ad

Answer this question