Sapper/building tool not working

  1. What do you want to achieve? Keep it simple and clear!
    I want to have a building system that is bound to a tool. Similiar to game like frontline karelia. So basically buildable defences
  2. What is the issue? Include screenshots / videos if possible!
    It does exactly nothing. Not even an error in the devconsol.
    grafik
    this is the setup
    and here are the scripts
    local placmentscript
local placementevent = repstorage:WaitForChild("placementevent")
local objects = repstorage:WaitForChild("Objects")
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

local Userinput = game:GetService("UserInputService")
local runservice = game:GetService("RunService")

local mouse = player:GetMouse()


local frame = script.Parent:WaitForChild("Frame")

local placingobjects = false
local rotatingobject = false

for i, Button in pairs(frame:GetChildren()) do
	
	if Button:IsA("TextButton") then
		Button.MouseButton1Click:Connect(function(click)

			if placingobjects == true then
				placingobjects = true
				local rotatingamount = 0
				local preqieobjects = objects:FindFirstChild(Button.Name):Clone()
				preqieobjects.Parent = game.Workspace
				for i, parts in pairs(preqieobjects:GetDescendants()) do
					if parts:IsA("BasePart") then
						parts.Transparency = 0.5
						parts.CanCollide = false
					end
				end
				
				
				Userinput.InputBegan:Connect(function(Key, GameProcessed)
					if not GameProcessed then
						if Key.KeyCode == Enum.KeyCode.R  then
							rotatingobject = true
							while rotatingobject == true do
								wait(0.1)
								rotatingamount += 2
								
							end
						end
					end
				end)
				Userinput.InputEnded:Connect(function(Key)
					if Key.KeyCode == Enum.KeyCode.R then
						rotatingobject = false
					end
					
				end)
				runservice.RenderStepped:Connect(function()
					if placingobjects == true then
						mouse.TargetFilter = preqieobjects 
						if preqieobjects:FindFirstChild("MainPart") then
							local objectcframe = CFrame.new(mouse.hit.Position.X,mouse.hit.Position.Y + preqieobjects.PrimaryPart.Size.Y /2,mouse.hit.Position.Z )
							local objectangles = CFrame.Angles(0,math.rad(rotatingamount),0)
							preqieobjects:SetPrimaryPartCFrame(objectcframe * objectangles)
						end
					end
				end)
				mouse.Button1Up:Connect(function()
					if placingobjects == true then
						placingobjects = false
						placementevent:FireServer(preqieobjects.Name,preqieobjects.PrimaryPart.CFrame)
						preqieobjects:Destroy()
					end
				end)	
					end 
			
		end)
	end

end


Serverscript

local event = repstorage:WaitForChild("placementevent")
local foldeer = repstorage:WaitForChild("Objects")

event.OnServerEvent:Connect(function(Player, preqieobjects, preqieobjectcframe)
	local object = foldeer:FindFirstChild(preqieobjects):Clone()
	object:SetPrimaryPartCFrame(preqieobjectcframe)
	object.Parent = game.Workspace
	
end) 
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried to search tutorials on youtube, look for grammaitical mistakes in the code. And try to rescript it. No sucess

Can anyone explain me why this isn’t working? I am not the best scripter so sorry if it’s some obvious mistake.