[Fixed] Help with a Placement system on button

I need help with a script the will select an object in an inventory, then click the place button

The Local Script
local equipped = script.Parent.Parent.Parent.Inventory.Equipped
local selected = script.Parent.Parent.Parent.Inventory.Selected
local location = script.Parent.Parent.Parent.Inventory.Location
local player = game.Players.LocalPlayer
local character = player.Character
local Mouse = player:GetMouse()

script.Parent.MouseButton1Click:Connect(function()
	
	equipped.Value = selected.Value
	
	if equipped.Value == nil or equipped.Value ~= selected.Value then
		
		print("Nothing Happened.")
		
	else
		
		local Model = selected.Value
		Model.Parent = workspace
		
		local GridSize = 1
		
		function Snap()
			
			PosX = math.floor(Mouse.Hit.X / GridSize + 0.5) * GridSize
			PosY = Model.PrimaryPart.Position.Y
			PosZ = math.floor(Mouse.Hit.Z / GridSize + 0.5) * GridSize				
			
		end
		
		function Movement()
			
			Mouse.TargetFilter = Model
			
			Snap()
			
			Model:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ))
			
		end
		
	end
	
end)

Mouse.Move:Connect(Movement)

image

Please ensure your post follows the Scripting Support category guidelines in the future. Your post is vague and doesn’t properly address the necessities of a help request. Don’t state your error and then post your whole code: help us through with information and addressing what you’ve attempted first.

That being said, look at your console carefully and address the problems. The main issue is that your function, Movement, is only declared in the scope of the function connected to MouseButton1Click of your GuiButton. You’re trying to connect a function out-of-scope that doesn’t exist.

Move the function out of MouseButton1Click.

2 Likes

Yep! That’s what I did. And alright, sorry for the inconvenience

Edit: Didn’t see the second half of colbert’s post.