Block not changing its position

so, i am making a building game and in my local script the choosen block do not move to the cursor’s hit

i tried to seek for solutions in forum but it seems that there is not too much forums about that and unsolved forums

i made the script to print the block’s position and it prints the exact hit of my cursor

i also tried to change the block’s position by the mouse hit by using mouse hit olny without BlockPOS instead

the local script:

local EventsFolder = script.Parent.Parent.Events.BuildingEvents
local BlockChoosen = EventsFolder.BlockChoosen
local PlaceBlock = EventsFolder.PlaceBlock

local Tool = EventsFolder.Parent.Parent

local BlockPOS = Vector3.new(0,0,0)
	local BlockROT = Vector3.new(0,0,0)
local Block = nil

 

	BlockChoosen.Event:Connect(function(BlockChoosen)
	
	Block = BlockChoosen:Clone()
	
	BlockChoosen.Parent = workspace.BlockPreviewArea
	end)

game.Players.LocalPlayer:GetMouse().Move:Connect(function()
	BlockPOS = game.Players.LocalPlayer:GetMouse().Hit.Position
	if Block == nil then else
		Block.Position = BlockPOS
	end

end)

Tool.Unequipped:Connect(function()
	if Block == nil then else
	Block:Destroy()
		Block = nil
		end
end)

game.Players.LocalPlayer:GetMouse().Button1Up:Connect(function()
	if Block == nil then else
		PlaceBlock:FireServer(BlockPOS, BlockROT, BlockChoosen)
	end
end)
2 Likes

Did you mean to make it BlockChoosen? Based on the context, it seems more likely that you meant for it to be

Block.Parent = workspace.BlockPreviewArea
1 Like
local EventsFolder = script.Parent.Parent.Events.BuildingEvents
local BlockChoosen = EventsFolder.BlockChoosen
local PlaceBlock = EventsFolder.PlaceBlock

local Tool = EventsFolder.Parent.Parent

local BlockPOS = Vector3.new(0,0,0)
local BlockROT = Vector3.new(0,0,0)
local Block = nil

BlockChoosen.Event:Connect(function(BlockChosen)
	Block = BlockChosen:Clone()
	Block.Parent = workspace.BlockPreviewArea
end)

game.Players.LocalPlayer:GetMouse().Move:Connect(function()
	BlockPOS = game.Players.LocalPlayer:GetMouse().Hit.p
	if Block then
		Block.CFrame = CFrame.new(BlockPOS)
	end
end)

Tool.Unequipped:Connect(function()
	if Block then
		Block:Destroy()
		Block = nil
	end
end)

game.Players.LocalPlayer:GetMouse().Button1Up:Connect(function()
	if Block then
		PlaceBlock:FireServer(BlockPOS, BlockROT, Block)
	end
end)

yeah i meant that, sorry for the confusion

yes, thats it! thanks for the solution. i shoud have tried change CFrame instead

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.