Before We begin here are some things you should know the Heirarchy
Problem: The following script does everything it is saposed to do, but when the part if following the mouse, and when I finally place it, it does not place right It looks like this , although i want to be placed like this , Also if i leave the mouse still while I'm in placing mode, the item will get closer and closer
Script
local cam = game.Workspace.CurrentCamera
local Item = game.ReplicatedStorage.Building.Walls.WoodenWall
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local enabled = script.Parent.Enabled
local amount = script.Parent.Amount
local Placing = false
script.Parent.MouseButton1Down:connect(function()
if enabled.Value == true then
enabled.Value = false
elseif enabled.Value == false then
enabled.Value = true
end
if Placing == true then
local Item2 = cam:WaitForChild('WoodenWall')
local Torso = game.Workspace:WaitForChild(player.Name).Torso
local mag = (Item2.Position - Torso.Position).magnitude
print(mag)
if mag <= 40 then
Item2:WaitForChild('bob'):remove()
Item2.Parent = game.Workspace
Item2.CFrame = mouse.Hit + Vector3.new(0, 50, 0)
Item2.CanCollide = true
Placing = false
enabled.Value = false
amount.Value = amount.Value - 1
end
end
end)
script.Parent.MouseButton2Down:connect(function()
if enabled.Value == true and amount.Value >= 1 then
local Item2 = Item:Clone()
Item2.Parent = cam
local selectionBox = Instance.new("SelectionBox",Item2) --We set its parent, but not where it's going to overlay
selectionBox.Adornee = Item2
selectionBox.Name = 'bob'
selectionBox.Color = BrickColor.new("Lime green")
Placing = true
repeat
wait(.1)
Item2.CFrame = mouse.Hit
until enabled.Value == false or amount.Value < 1
end
end)

1 comment
how do i use target fitler