I’m making a placement tool but I’m having trouble implementing a rotate function into the placement. Can anyone help me?
Code:
LocalScript "PlacementScript"
local mouse = game.Players.LocalPlayer:GetMouse()
local off = false
script.Parent.Equipped:Connect(function(toolMouse)
if mouse ~= nil then
local clonedBrick = game.ReplicatedStorage.ConcreteBarrier:Clone()
mouse.TargetFilter = clonedBrick
clonedBrick.Transparency = .5
clonedBrick.CanCollide = false
clonedBrick.Parent = workspace
while mouse ~= nil do
clonedBrick.Position = mouse.Hit.p + Vector3.new(0, 1.25, 0)
wait()
if off then
clonedBrick:Destroy()
off = false
break
end
end
end
end)
script.Parent.Activated:Connect(function()
local BrickToPlace = game.ReplicatedStorage.ConcreteBarrier:Clone()
local pos = mouse.Hit.p + Vector3.new(0, 1.25, 0)
script.Parent.AddBlock:FireServer(pos)
end)
script.Parent.Unequipped:Connect(function()
off = true
end)
ServerScript "FireEvent"
script.Parent.AddBlock.OnServerEvent:Connect(function(plr, pos)
local btp = game.ReplicatedStorage.ConcreteBarrier:Clone()
btp.Parent = workspace
btp.CanCollide = true
btp.Position = pos
btp.Name = plr.Name.."'s Barrier"
end)
script.Parent.RemoveBlock.OnServerEvent:Connect(function(plr, block)
if block.Name == plr.Name then
block:Destroy()
end
end)