I need help of making a block placement tool. The issue I have is that the block doesn’t go where I click. I’ve tried looking at numerous topics about this and I can’t find any solution.
Client script
–local mouse = player:GetMouse()
local RS = game:GetService(‘ReplicatedStorage’)
local tool = script.Parent
local Event = RS:WaitForChild(‘PlaceBlock’)
local pos
local block = game.ReplicatedStorage.Block
script.Parent.Activated:Connect(function()
local target = mouse.Target
if target then
print(target.Position)
if (target.Position - player.Character.HumanoidRootPart.Position).magnitude <= 12 then
local pos = target
Event:FireServer(target,pos,block)
end
end
end)
server script
–local RS = game:GetService(‘ReplicatedStorage’)
local Event = RS:WaitForChild(‘PlaceBlock’)
Event.OnServerEvent:Connect(function(player,target,pos,Block)
local clonedBlock = Block:Clone()
clonedBlock.Position = target.Position
clonedBlock.Parent = game.Workspace
end)