Placement System Not Working?

  1. What do you want to achieve?

I’ve created a placement system; however, the models within the “PlacementItem” in ReplicatedStorage aren’t showing up in the ScrollingFrame. I’ve created a “Template” for each model to appear in and currently only have one model in the folder.

  1. What is the issue?

I’ve tried to check for any errors in the output; however, I’m not getting any so it has been difficult for me to understand what’s going wrong. I’m not even sure if my placement system even works as it should because the models don’t appear in the inventory.

  1. What solutions have you tried so far?

I’ve looked over the scripts in the ScrollingBar, the Mod.Script in Rep.Storage, and in the Inventory & Placement scripts in ServerScriptStorage. I can’t find anything that seems to be creating this problem.

I thought I’d come to the DevForum to receive some assistance from the intelligent individuals of the forum who know much more about scripting than I do! I just started to learn how to script about 3 months ago and it’s been a slow process; however, I’m looking forward to learning how to be better from everyone here!

I’ve created a model that you can download to try and dissect the Placement System yourself in Studio since it’d probably be much more useful than reading over all the scripts in this post.

Here’s a link to the model: Auevi's Placement System (NOT WORKING YET) - Roblox

The instructions are in the Model—if you need them :slight_smile:

Also, I know that the GUI placements are probably all wacky, I plan on fixing that in the future but I want to get the main issues fixed before doing so!

Here are all the scripts that I think are related to the issue I’m having:

AutoResizeScrollingFrame Script:

local lua_plus = require(script:WaitForChild("lua_plus"))
local ScrollingFrame = script.Parent 
local UIListLayout = script.Parent:WaitForChild("UIListLayout") 
local UpdateDirection = Enum.ScrollingDirection.Y 
 
lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
ScrollingFrame.DescendantAdded:Connect(function()
	wait(0.1)
	lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
end)

ScrollingFrame.DescendantRemoving:Connect(function()
	wait(0.1)
	lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
end)

Screen Shot 2022-07-23 at 12.56.13 PM

Local Script in ScrollingFrame:

local lua_plus = require(script:WaitForChild("lua_plus"))
local ScrollingFrame = script.Parent 
local UIListLayout = script.Parent:WaitForChild("UIListLayout") 
local UpdateDirection = Enum.ScrollingDirection.Y 
 
lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
ScrollingFrame.DescendantAdded:Connect(function()
	wait(0.1)
	lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
end)

ScrollingFrame.DescendantRemoving:Connect(function()
	wait(0.1)
	lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
end)

Screen Shot 2022-07-23 at 12.56.56 PM

Local Script in “Template” Frame:

local lua_plus = require(script:WaitForChild("lua_plus"))
local ScrollingFrame = script.Parent 
local UIListLayout = script.Parent:WaitForChild("UIListLayout") 
local UpdateDirection = Enum.ScrollingDirection.Y 
 
lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
ScrollingFrame.DescendantAdded:Connect(function()
	wait(0.1)
	lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
end)

ScrollingFrame.DescendantRemoving:Connect(function()
	wait(0.1)
	lua_plus.update_canvas_based_on_children(ScrollingFrame, UIListLayout, UpdateDirection)
end)

Screen Shot 2022-07-23 at 12.57.43 PM

Inventory Script in ServerScriptStorage:

local DataStoreService = game:GetService("DataStoreService"):GetDataStore("SaveData")

 
game.Players.PlayerAdded:Connect(function(player)
	local plrid = "id_"..player.userId
	local InventoryFolder = Instance.new("Folder")
	InventoryFolder.Name = "InventoryFolder"
	InventoryFolder.Parent = player
	local FolderToStoreBuilding=  Instance.new("Folder",game.Workspace)
	FolderToStoreBuilding.Name = player.Name .."FolderToStoreBuilding"
	----------<<<<<<Make sure that the NAME OF YOUR PLACEMENT Item is same as the Name Of the IntValue 
	local TeaParty = Instance.new("IntValue",InventoryFolder)
	TeaParty.Name = "Tea Party"  
	TeaParty.Value=  0
	--local Doorway =Instance.new("IntValue",InventoryFolder)
	--Doorway.Value = 0
	--Doorway.Name = "Doorway"
	--local LargeTable =Instance.new("IntValue",InventoryFolder)
	--LargeTable.Value = 0
	--LargeTable.Name = "LargeTable"
	--local Walls =Instance.new("IntValue",InventoryFolder)
	--Walls.Value = 0
	--Walls.Name = "Walls"    
	---------<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>....
	
 local PlotClaimed = Instance.new("BoolValue",player)
	PlotClaimed.Value = false
	
	PlotClaimed.Name = "PlotClaimed"
	
	local GetData = DataStoreService:GetAsync(plrid)
	if GetData then


		TeaParty.Value = GetData[1]
		--Doorway.Value = GetData[2]
		--Walls.Value = GetData[3]
		--LargeTable.Value = GetData[4]
 
	else

		local CurrencySave = {TeaParty.Value--,Doorway.Value,LargeTable.Value,Walls.Value
		}
		DataStoreService:GetAsync(plrid, CurrencySave)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)  
	if plr:WaitForChild("PlotClaimed").Value == true then
		for i ,v in pairs(game.Workspace:WaitForChild("PlotFolder"):GetDescendants()) do
			if v:IsA("StringValue") and v.Name == "PlayerName"  then
				if v.Value == tostring(plr.Name) then
					v.Value = ""
					v.Parent:WaitForChild("PlotClaim").Value = false
 v.Parent:WaitForChild("PlayerNamePart"):FindFirstChild("SurfaceGui").PlayerNameLabel.Text = ""
				end
			end
		end
	end
	DataStoreService:SetAsync("id_"..plr.UserId, {plr.InventoryFolder.TeaParty.Value
		--, plr.InventoryFolder.Doorway.Value,
		--plr.InventoryFolder.Walls.Value,
		--plr.InventoryFolder.LargeTable.Value 
	})
end)

InventoryModuleScript in ReplicatedStorage:

local module = {}
module.InventoryInfo = {
	["TeaParty"] = {
		["ItemName"] = "Tea Party",
		["Description"] = "Blahblahblah",
		["Icon"] = "rbxassetid://".. "4333953029"
}--,
	--ADD NEW MODEL HERE
	--["Tea Party"] = {
		--["ItemName"] = "Tea Party",
		--["Description"] = "Blahblahblah"
	--["Icon"] = "place image ID here",
	}
return module

Thank you soooo much for your help! It’s greatly and truly appreciated. I wanted to make this a model that players can use in their games and to also learn how to script as well :slight_smile: I also would like to use it for one of my games as well.

Please let me know if I can give you anymore information!

1 Like

Could you show a picture of where you’re storing the furniture models?

(Just reread the post and saw that you mentioned where they are)
Could you perhaps explain where you’re adding the buttons to the player’s inventory? Looking through the code I can’t find anything related to the placementitem folder in your code.

I just realized that I had the folder named the wrong name! I fixed it in the model I’ve provided in this post. I’ve actually fixed the ScrollingFrame issue; however, the model doesn’t appear & I’m not able to place anything.

EDIT: I’ve updated the model so that it’s currently relevant to the issue I’m having!

1 Like

I’ll check that out in an hour or two, anything in the output?

1 Like

Thank you! I appreciate it :slight_smile: There is nothing shown in the output, no errors.

Is there an uncopylocked copy of the place? I’m receiving a lot of errors with the model provided.

1 Like

I will create one now! Currently trying to figure out how to uncopylock the game (Roblox changed it from the last time I’ve done it) :sweat_smile:

EDIT: Alrighty, I think it’s uncopylocked now :slight_smile:

EDIT: I believe I might’ve forgotten to put the Models into the InventoryFolder in the model when I published it. Let me fix that too!

image

1 Like

Thank you for pointing that out!

I’ve tried clicking on the error to open up the script it’s within but it won’t let me do so. I’m quite new to scripting & was wondering how I would go about fixing the issue? Sorry for asking a silly question :sweat_smile:

EDIT: Okay, I’ve fixed this issue and have republished a new version of the uncopylocked experience! However, now when I try to use the item this error appears:

I assume it’s part of this script:

local InventoryMod = require(game.ReplicatedStorage.InventoryModuleScript)
local RunService = game:GetService("RunService")
local PlacementFolder = game:GetService("ReplicatedStorage"):WaitForChild("InventoryFolder")
local UseEvent = game:GetService("ReplicatedStorage"):WaitForChild("UseItem")
local plr = game.Players.LocalPlayer

local UIS = game:GetService("UserInputService")
local placing = false
local mouse = plr:GetMouse()
local maxplacingdistance = 27
local CanRotate = false
script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Parent.Name == "Template" then return end
	
	if placing == false then
		placing = true
		
		wait(.1)
		script.Parent.Visible = false
		script.Parent.Parent.No.Visible = false
		
		script.Parent.Parent.Parent.Parent.Delete.Visible = false
		script.Parent.Parent.Use.Visible = true
		script.Parent.Parent.Parent.Visible = false
		script.Parent.Parent.Parent.Parent.Open.Visible = false
		script.Parent.Parent.Parent.Parent.SearchBar.Visible = false
		script.Parent.Parent.Parent.Parent.Exit.Visible = true
		script.Parent.Parent.Parent.Parent.RotateButton.Visible = true
		local PreviewClone = PlacementFolder:WaitForChild(tostring(script.Parent.Parent.Name)):Clone()
		PreviewClone.Parent = game.Workspace
		local RotateAmount = 0
		for i ,v in pairs(PreviewClone:GetDescendants()) do
			if v:IsA("BasePart") then
				v.Transparency = 0.5
				
				v.CanCollide = false
				
			end
		end
		PreviewClone.MovePart.Color = Color3.fromRGB(43,255,66)
		UIS.InputBegan:Connect(function(Key, IntProcess)
			if not IntProcess then
				if Key.KeyCode == Enum.KeyCode.R then
					CanRotate = true
					script.Parent.Parent.Parent.Parent.RotateButtonMobile.Visible = true
					script.Parent.Parent.Parent.Parent.RotateBar.Visible = true
					script.Parent.Parent.Parent.Parent.RotateButton.Text = "X(Rotate)On"
					script.Parent.Parent.Parent.Parent.RotateButton.BackgroundColor3 = 
						Color3.fromRGB(48,255,141)
					if script.Parent.Parent.Parent.Parent.RotateBar.Text ~= "" or 
						tonumber(script.Parent.Parent.Parent.Parent.RotateBar.Text)~= nil then
						if CanRotate == true then
							
							if tonumber(script.Parent.Parent.Parent.Parent.RotateBar.Text) > 180 then
								script.Parent.Parent.Parent.Parent.RotateBar = "180"
								RotateAmount = 180
							else
								
				RotateAmount = RotateAmount+ tonumber(script.Parent.Parent.Parent.Parent.RotateBar.Text)
							end
						end
						
					end
				end
			end
		end)
		UIS.InputEnded:Connect(function(Key)
			
			if Key.KeyCode == Enum.KeyCode.X then
				
				CanRotate = false
				script.Parent.Parent.Parent.Parent.RotateButtonMobile.Visible = false
				script.Parent.Parent.Parent.Parent.RotateBar.Visible = false
				script.Parent.Parent.Parent.Parent.RotateButton.Text = "R(Rotate):Off"
				
				script.Parent.Parent.Parent.Parent.RotateButton.BackgroundColor3=
					Color3.fromRGB(255,86,84)
				
			end
			
		end)
		script.Parent.Parent.Parent.Parent.RotateButtonMobile.MouseButton1Click:Connect(function()
			if CanRotate == true then
				if tonumber(script.Parent.Parent.Parent.Parent.RotateBar.Text) > 180 then
					
					script.Parent.Parent.Parent.Parent.RotateBar = "180"
					RotateAmount = 180
				else
					RotateAmount = RotateAmount+ tonumber(script.Parent.Parent.Parent.Parent.RotateBar.Text)
					
				end
			end
		end)
		RunService.RenderStepped:Connect(function()
			if placing == true then
				mouse.TargetFilter = PreviewClone
				if PreviewClone:FindFirstChild("MovePart") then
					
					local PreviewClone = CFrame.new(mouse.Hit.Position.X,mouse.Hit.Position.Y
						+PreviewClone.PrimaryPart.Size.Y/2,
						mouse.Hit.Position.Z)
					local Angles = CFrame.Angles(0,math.rad(RotateAmount),0)
					PreviewClone:SetPrimaryPartCFrame(PreviewClone*Angles)
				end
			end
		end)
		script.Parent.Parent.Parent.Parent.Exit.MouseButton1Click:Connect(function()
			script.Parent.Parent.Parent.Parent.Open.Visible = true
			script.Parent.Parent.Parent.Parent.ScrollingFrame.Visible = true --might change
			script.Parent.Parent.Parent.Parent.RotateButton.Visible = false
			script.Parent.Parent.Parent.Parent.SearchBar.Visible = true --might change
			script.Parent.Parent.Parent.Parent.Delete.Visible = true
			script.Parent.Parent.Parent.Parent.Exit.Visible = false
			script.Parent.Parent.Parent.Parent.RotateBar.Visible = false
			
			PreviewClone:Destroy()
			
		end)
		
		mouse.Button1Up:Connect(function()
			if placing == true then
				
				placing = false
				
				script.Parent.Parent.Parent.Parent.Exit.Visible = false
				script.Parent.Parent.Parent.Parent.ScrollingFrame.Visible = true
				script.Parent.Parent.Parent.Parent.Open.Visible = true
				script.Parent.Parent.Parent.Parent.Delete.Visible = true
				script.Parent.Parent.Parent.Parent.RotateButton.Visible = false
				script.Parent.Parent.Parent.Parent.SearchBar.Visible = true
				script.Parent.Parent.Parent.Parent.RotateBar.Visible = false
				
				if PreviewClone ~= nil  then
					
					UseEvent:FireServer(PreviewClone.Name,PreviewClone.PrimaryPart.CFrame)
					PreviewClone:Destroy()
					script.Parent.Parent.Parent.Parent.Exit.Visible = false
					script.Parent.Parent.Parent.Parent.ScrollingFrame.Visible = true
					script.Parent.Parent.Parent.Parent.Open.Visible =  true
					script.Parent.Parent.Parent.Parent.Delete.Visible = true
					script.Parent.Parent.Parent.Parent.RotateButton.Visible = false
					script.Parent.Parent.Parent.Parent.SearchBar.Visible = true
					script.Parent.Parent.Parent.Parent.RotateButton.Visible = false
				end
			end
		end)
	end
end)

Screen Shot 2022-07-24 at 10.01.49 AM

EDIT: I just decided to add it to this reply instead.

local PreviewClone = CFrame.new(mouse.Hit.Position.X,mouse.Hit.Position.Y
						+PreviewClone.PrimaryPart.Size.Y/2,
						mouse.Hit.Position.Z)
					local Angles = CFrame.Angles(0,math.rad(RotateAmount),0)
					PreviewClone:SetPrimaryPartCFrame(PreviewClone*Angles)

Your issue is here. You’re attempting to call SetPrimaryPartCFrame on a CFrame value when it expects to be called on a ‘Model’ instance instead.

Try doing this instead

local Position = CFrame.new(mouse.Hit.Position.X,mouse.Hit.Position.Y
						+PreviewClone.PrimaryPart.Size.Y/2,
						mouse.Hit.Position.Z)
					local Angles = CFrame.Angles(0,math.rad(RotateAmount),0)
					PreviewClone:SetPrimaryPartCFrame(Position*Angles)
1 Like

Yes! it works now :slight_smile: Thank you so much!! :heart:

I’m now getting an error when I delete the models and my rotation system isn’t working :confused:

I do feel bad for taking your time—but let me know if you’d be able to help!

1 Like

Show me the errors/warnings please.

1 Like

Output:

ServerScriptService.Placement:20: attempt to index nil with ‘Destroy’

local DeleteItem = game:GetService("ReplicatedStorage"):WaitForChild("DeleteItem")
UseEvent.OnServerEvent:Connect(function(Player,PreviewClone,PreviewCFrame)
	local Real = PlaceFolder:FindFirstChild(PreviewClone):Clone()
	
	Real:SetPrimaryPartCFrame(PreviewCFrame)
	Real.Parent = game.Workspace:FindFirstChild(Player.Name .."FolderToStoreBuilding")
	
	
end)
DeleteItem.OnServerEvent:Connect(function(Player, mouseTarget)
	if mouseTarget.Name == "MovePart" and mouseTarget:IsA("BasePart") then--I assume baseplate change to part? then
		if mouseTarget ~= nil then
			Player.InventoryFolder:FindFirstChild(mouseTarget.Parent.Name).Value=
				Player.InventoryFolder:FindFirstChild(mouseTarget.Parent.Name).Value+1
			wait()
			wait(.1)
			mouseTarget.Parent:Destroy()
		end
	end
end)

EDIT: Also this is another error as well:

ServerScriptService.Placement:14: attempt to index nil with ‘Name’

1 Like

Try removing the waits. Also try printing the mouseTarget.Parent before destroying

1 Like

That worked! But now I’m getting this error:

Players.Auevi.PlayerGui.InventoryGui.ScrollingFrame.LocalScript.Template.LocalScript:6: attempt to index nil with ‘Name’

while wait() do
	local plr = game.Players.LocalPlayer
	repeat wait()
	until
	plr.Character
	if script.Parent.Name == "Template" then return end
	if plr.InventoryFolder:FindFirstChild(tostring(script.Parent.Name)).Value <=0 then
		script.Parent:Destroy()
	end
end

EDIT: This only happens once I delete the item— but it seems like I’m still able to place the item again and doesn’t really impact anything?

1 Like

Try doing

if script.Parent and script.Parent.Name == "Template" then
1 Like

That has happened to me in the past… What I do is instead of putting the item images in the frame itself, I make an invisible frame within the scrolling frame called “Content” So when your script runs, it puts the items in an invisible frame that is compatible with the one shown. I know it might sound not very easy although I THINK there are some tutorials on youtube for it.

  • Best of luck, Wolf

Yes :slight_smile: That got rid of the error! Thank you so much!

1 Like