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

Why isn't this taking the Model inside of the Part? [Solved]

Asked by 6 years ago
Edited 6 years ago

http://prntscr.com/gwrfn8 Problem: Not copying the Bed Model inside of it

Errors: None

-- Initialization
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
-- UI
ScreenGui = script.Parent
Purchase = ScreenGui:WaitForChild("Place")
-- Varaibles
InPlaceMode = false
NewTurret = nil
CanPlace = false
-- Models
Turrets = game.ReplicatedStorage:WaitForChild("Turrets") 
BaseTurret = Turrets:WaitForChild("Turret01")

--Hold shift to multibuy

mouse.Button1Down:connect(function()
    if InPlaceMode == true and CanPlace == true then
        InPlaceMode = false
        if NewTurret and NewTurret:FindFirstChild("SelectionBox") then
            NewTurret:FindFirstChild("SelectionBox"):Destroy()
            for i,v in pairs (NewTurret:GetChildren()) do
                if v:IsA("BasePart") then
                    v.Transparency = 0
                end
            end
        end
    end
end)

Purchase.MouseButton1Down:Connect(function()
    if not InPlaceMode then
        InPlaceMode = true
        NewTurret = BaseTurret:Clone()
        NewTurret.Parent = game.Workspace
        local SelectionBox = Instance.new("SelectionBox",NewTurret)
        SelectionBox.Color3 = Color3.new(0/255, 255/255, 0/255)
        SelectionBox.Adornee = NewTurret
        mouse.TargetFilter = NewTurret
        while InPlaceMode  do
            print("henlo")
            wait()
            local Hit = mouse.Hit.p
            local X0, Y0, Z0 = Hit.X - math.fmod(Hit.X,4), Hit.Y - math.fmod(Hit.Y,1), Hit.Z - math.fmod(Hit.Z,4)
            if mouse.Target and mouse.Target.Name == "BuildSpace" then
                NewTurret.Position = (Vector3.new(X0,Y0,Z0))
                SelectionBox.Color3 = Color3.new(0/255, 255/255, 0/255)
                SelectionBox.Adornee = NewTurret
                CanPlace = true
                for i,v in pairs (NewTurret:GetChildren()) do
                    if v:IsA("BasePart") then
                        v.Transparency = 0
                    end
                end
            elseif mouse.Target then
                --NewTurret:MoveTo(Vector3.new(X0,Y0,Z0))
                CanPlace = false
                SelectionBox.Color3 = Color3.new(255/255, 71/255, 74/255)
                for i,v in pairs (NewTurret:GetChildren()) do
                    if v:IsA("BasePart") then
                        --v.Color = Color3.new(255/255, 71/255, 74/255)
                        v.Transparency = 1
                        SelectionBox.Adornee = nil
                    end
                end
            end
        end
    end
end)





0
Giving us 70 lines of code and asking what is wrong with it is a surefire way to not get a response. Give us just the code that is causing the problem. No one feels like sorting through the code and finding the section in question and the figuring the problem. lukeb50 631 — 6y
0
But if you need an off the top of the head answer, Check the "Archivable" Property of the model not being cloned. If it is false that is your problem lukeb50 631 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Use Model:MoveTo(Vector3) on line 46

-- Initialization
Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
-- UI
ScreenGui = script.Parent
Purchase = ScreenGui:WaitForChild("Place")
-- Varaibles
InPlaceMode = false
NewTurret = nil
CanPlace = false
-- Models
Turrets = game.ReplicatedStorage:WaitForChild("Turrets") 
BaseTurret = Turrets:WaitForChild("Turret01")

--Hold shift to multibuy

mouse.Button1Down:connect(function()
    if InPlaceMode == true and CanPlace == true then
        InPlaceMode = false
        if NewTurret and NewTurret:FindFirstChild("SelectionBox") then
            NewTurret:FindFirstChild("SelectionBox"):Destroy()
            for i,v in pairs (NewTurret:GetChildren()) do
                if v:IsA("BasePart") then
                    v.Transparency = 0
                end
            end
        end
    end
end)

Purchase.MouseButton1Down:Connect(function()
    if not InPlaceMode then
        InPlaceMode = true
        NewTurret = BaseTurret:Clone()
        NewTurret.Parent = game.Workspace
        local SelectionBox = Instance.new("SelectionBox",NewTurret)
        SelectionBox.Color3 = Color3.new(0/255, 255/255, 0/255)
        SelectionBox.Adornee = NewTurret
        mouse.TargetFilter = NewTurret
        while InPlaceMode  do
            print("henlo")
            wait()
            local Hit = mouse.Hit.p
            local X0, Y0, Z0 = Hit.X - math.fmod(Hit.X,4), Hit.Y - math.fmod(Hit.Y,1), Hit.Z - math.fmod(Hit.Z,4)
            if mouse.Target and mouse.Target.Name == "BuildSpace" then
                NewTurret.Bed:MoveTo(Vector3.new(X0,Y0,Z0))
                SelectionBox.Color3 = Color3.new(0/255, 255/255, 0/255)
                SelectionBox.Adornee = NewTurret
                CanPlace = true
                for i,v in pairs (NewTurret:GetChildren()) do
                    if v:IsA("BasePart") then
                        v.Transparency = 0
                    end
                end
            elseif mouse.Target then
                --NewTurret:MoveTo(Vector3.new(X0,Y0,Z0))
                CanPlace = false
                SelectionBox.Color3 = Color3.new(255/255, 71/255, 74/255)
                for i,v in pairs (NewTurret:GetChildren()) do
                    if v:IsA("BasePart") then
                        --v.Color = Color3.new(255/255, 71/255, 74/255)
                        v.Transparency = 1
                        SelectionBox.Adornee = nil
                    end
                end
            end
        end
    end
end)





Ad

Answer this question