so i am trying to make a block preview for placing my blocks, and it does not work for some reason:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local UIS = game:GetService('UserInputService')
local RS = game:GetService('ReplicatedStorage')
local tool = script.Parent
local Event = RS:WaitForChild('PlaceBlock')
local pos
-- Surface Detection
local function Surface(surface)
if surface.Name == "Top" then
pos = Vector3.new(0,4,0)
elseif surface.Name == "Bottom" then
pos = Vector3.new(0,-4,0)
elseif surface.Name == "Front" then
pos = Vector3.new(0,0,-4)
elseif surface.Name == "Back" then
pos = Vector3.new(0,0,4)
elseif surface.Name == "Left" then
pos = Vector3.new(-4,0,0)
elseif surface.Name == "Right" then
pos = Vector3.new(4,0,0)
end
return pos
end
local num = 1
local blocks = RS.Blocks:GetChildren()
local Block_Choice = blocks[1]
numberOfBlocks = #blocks
script.Parent.Activated:Connect(function()
local target = mouse.Target
if target then
local surface = mouse.TargetSurface
local pos = Surface(surface)
Event:FireServer(target,pos,Block_Choice)
end
end)
-- the selection part
mouse.Move:Connect(function()
if tool.Equipped == true then
local block = game.ReplicatedStorage.Blocks.Part:Clone()
block.CFrame = mouse.Hit
end
end)
as you can see i clearly stated that if the mouse move the clone will show up and player can see it locally…what have i done wrong in this script?
edit
HMMMM Ima add a logic gate like so:
tool.Equipped:Connect(function()
equipped = true
end)
tool.Unequipped:Connect(function()
equipped = false
end)