Placement System Error

So, I found this open source script somewhere on the internet that function as a placement system, I followed the procedures to make it work as intended. Once I finished the script it seems like it has a error because it doesn’t appear on my screen. So here’s the script

local ReplicatedStorage	= game:GetService("ReplicatedStorage")
local PlaceStructure = ReplicatedStorage:WaitForChild("PlaceStructure")
local Structures = ReplicatedStorage:WaitForChild("Structures") 

local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local player = game.Players.LocalPlayer
local StructureFrame = script.Parent.StructureFrame
local char = player.Character or player.Character:Wait()
local HumanoidRootPart = char:WaitForChild("HumanoidRootPart")

local mouse = player:GetMouse()

local yBuildingOffset = 5 
local maxPlacingDistance = 50
local rKeyIsPressed = false
local placingStructure = false

for _, structureButton in pairs(StructureFrame:GetChildren()) do
	if structureButton:IsA("TextButton") then
		structureButton.MouseButton1Up:Connect(function()
			
			StructureFrame.Visible = false
			
			local yOrientation = 0 
			local goodToPlace = false
			local placeStructure
			
			if placingStructure == false then 
				placingStructure = true
				
				local clientStructure = Structures:FindFirstChild(structureButton.Name):Clone()
				clientStructure.BrickColor = BrickColor.new("Forest green")
				clientStructure.Material = "Neon"
				clientStructure.CanCollide = false
				clientStructure.Parent = game.Workspace
				
				local startingCFrame = CFrame.new(0, -2, -15)
				clientStructure.CFrame = HumanoidRootPart.CFrame:ToWorldSpace(startingCFrame)
				
				RunService.RenderStepped:Connect(function()
					local mouseRay = mouse.UnitRay
					local castRay = Ray.new(mouseRay.Origin, mouseRay.Direction * 1000)
					local ignoreList = (clientStructure, char)
					local hit, position = workspace:FindPartOnRayWithIgnoreList(castRay, ignoreList)
					
					if hit and (HumanoidRootPart.Position - clientStructure.Position).Magnitude < maxPlacingDistance then
						goodToPlace = true
						clientStructure.BrickColor = BrickColor.new("Forest green")
					else
						goodToPlace = false
						clientStructure.BrickColor = BrickColor.new("Crimson")				    
					end 
					
					local newAnglesCFrame = CFrame.Angles(0, math.rad(yOrientation), 0)
					local newCFrame = CFrame.new(position.X, position.Y + yBuildingOffset, position.Z)
					clientStructure.CFrame = newCFrame * newAnglesCFrame
				end)
				
				UIS.InputBegan:Connect(function(input)
					if input.KeyCode == Enum.KeyCode.R then 
						rKeyIsPressed = true
						
						local rotationSpeed = 5
						while rKeyIsPressed do
							wait()
							if placingStructure == true then
								yOrientation = yOrientation + rotationSpeed
							end
						end
					end
				end)
				
				UIS.InputEnded:Connect(function(input)
					if input.KeyCode == Enum.KeyCode.R then
						rKeyIsPressed = false
					end
				end)
				
				UIS.InputBegan:Connect(function(input)
					if input.UserInputType == Enum.UserInputType.MouseButton1 then
						if placingStructure == true then
							if goodToPlace == true then
								local StructureCFrame = clientStructure.CFrame
								placedStructure = PlaceStructure:InvokeServer(clientStructure.Name, StructureCFrame)
								
								if placedStructure == true then
									placingStructure = false 
									clientStructure:Destroy()
									StructureFrame.Visible = true
								end
							end
						end
					end				
				end)
			end
		end)
	end
end

I don’t have any experience in scripting so I have no clue what’s wrong with it. So if you ever know what is the error please let me know and it will help me a ton.

This is a script made to work with UI based on someone’s game. if you don’t have the UI along with it, it won’t work.

I have the UI. This specific part of the script is not working properly.

Can you share the file then? because just its a little hard to understand the problem.

image
Theres also script named “RemoteHandler” here it is

local ReplicatedStorage	= game:GetService("ReplicatedStorage")
local PlaceStructure = ReplicatedStorage:WaitForChild("PlaceStructure")
local Structures = ReplicatedStorage:WaitForChild("Structures") 

PlaceStructure.OnServerInvoke = function(player, structureName, StructureCFrame)
	
	local crafted 
	local realStructure = Structures:FindFirstChild(structureName):Clone()
	
	if realStructure then
		realStructure.CFrame = StructureCFrame
		realStructure.Parent = game.Workspace
		crafted = true
	else
		crafted = false
	end
	
	return crafted
end

@KreativeKendiYT any thoughts?

  1. check if there’s a new part in the workspace upon clicking a structure/block button
  2. check if the remote function is invoked (with a print)
  3. is there any errors on the console/output?

as @KreativeKendiYT said, it would be helpful to provide the files to further debug the problem

1 Like

Okay,

Theres no new part spawned in.

image
It responded.


This is the error I got.

this is a very late response but if you’d havent yet fixed this, replace local ignoreList = (clientStructure, char) with local ignoreList = {clientStructure, char}, also keep in mind workspace:FindPartOnRayWithIgnoreList is deprecated

1 Like

That works, it closes the UI but, it doesn’t show up the part that I selected. It’s fine if you took long to respond, at least some progress have been made. Thank you!


I also put a print message on RemoteHandler and it seems like it didn’t work(?)

check your structures folder, is there any structure that matches the button’s name?

(for some reason the forum kept this topic as tracking)

1 Like

i was gonna say, maybe you didn’t put RemoteHandler in ServerScriptService. Server scripts only work there or in workspace.

though the errors say they are occuring far before the script would invoke the remote for RemoteHandler to run.

can you send a picture of the Explorer so we can see where everything is and ensure things are named correctly? As he said, the structures need the same name as the button that selects them.

1 Like

@vicy98
I changed the name of the structure as the UI shows, It works but there is some issues I saw

  1. The part is not exactly on the cursor

  2. It duplicates the same block if you’re looking down

  3. When you selected the other block the grass still appear inside of it. Just like number 2(if you already interacted with grass)


The RemoteHandler works now

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.