Help with a build system

Hello, I am doing a build system and I am having some problems, I need to make that when I press the button it is instance the part in the mouse position and if I press the R the part can be rotated, how do I do that? :frowning:

image

localscript:

local UIS = game:GetService("UserInputService")
local button = script.Parent

button.MouseButton1Click:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("Check 1")
		
		local player = game.Players.LocalPlayer
		local mouse = player:GetMouse()
		
		local build = Instance.new("Part")
		build.Parent = workspace
		
		mouse.TargetFilter = build
		
		local RunService = game:GetService("RunService")

		local RATE_PER_SECOND = 2

		RunService.RenderStepped:Connect(function(step)
			local increment = RATE_PER_SECOND * step
			build.Position = mouse.Hit.p
			mouse.Hit.p = increment
		end)
		
		if input.UserInputType == Enum.KeyCode.R then
			print("rotating")
		end
		
	end
end)
Code:
local UIS = game:GetService("UserInputService")
local Mouse = game:GetService("Players").LocalPlayer:GetMouse()

local build = Instance.new("Part",workspace)
Mouse.TargetFilter = build

UIS.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        print("Check 1")
        -- More code --
    elseif input.KeyCode == Enum.KeyCode.R then
        print("rotating")
        -- More code --
    end
end)

game:GetService("RunService").RenderStepped:Connect(function()
    build.Position = Mouse.Hit.p
end)

It would only be necessary to add a RemoteEvent so that everyone can see what you put.

1 Like

thanks you @SOTR654 :smiley: :smiley:

You’re welcome, happy to help ^ - ^

1 Like