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

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

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)





2 comments

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.

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

1 answer

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)





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