I want to make a build GUI
When I try to set the parts position or cframe to the mouse it does not stay straight and only goes towards my camera.
I have tried youtube.com
I have set the part’s CFrame to my Mouse.Hit ‘Also Known As CFrame’ But when I set it, it just looks towards my camera and goes towards my camera which I do not want.
--Ignore how bad this is lol my first time
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local UIS = game:GetService("UserInputService")
local clicked = false
script.Parent.Activated:Connect(function()
local part = Instance.new("Part")
part.Size = Vector3.new(2,2,2)
part.Transparency = 0.5
part.Anchored = true
part.CanCollide = false
part.Parent = workspace
repeat
part.CFrame = Mouse.Hit
wait()
until clicked == true
if clicked == false then return end
part.CFrame = part.CFrame
part.Transparency = 0
end)
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
clicked = true
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
clicked = false
end
end)