when you hover over a block its supposed to show a 0.5 transparent block. The block has to be named "Cannotdelete" so you can hover over it. But the script is not working. Please somebody tell me why. Gives me an error that says: MouseEnter is not a valid member of Part "Players.PreviousSchmuck.Backpack.PlaceBlock.Handle" - Client - LocalScript:14
local player = game.Players.LocalPlayer
local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local mouse = player:GetMouse()
local PlaceBlock = Instance.new("Part")
PlaceBlock.Size = Vector3.new(3,3,3)
PlaceBlock.Anchored = true
PlaceBlock.CanCollide = false
PlaceBlock.Transparency = 0.5
local placing = false
handle.MouseEnter:Connect(function()
if tool.Parent == player.Character and placing == false then
placing = true
PlaceBlock.Parent = workspace
end
end)
handle.MouseLeave:Connect(function()
if placing == true then
placing = false
PlaceBlock:Destroy()
end
end)
local function placeBlock(target, surface)
if surface.Name == "Top" then
PlaceBlock.CFrame = CFrame.new(target.Position + Vector3.new(0,1.5,0))
elseif surface.Name == "Bottom" then
PlaceBlock.CFrame = CFrame.new(target.Position + Vector3.new(0,-1.5,0))
elseif surface.Name == "Right" then
PlaceBlock.CFrame = CFrame.new(target.Position + Vector3.new(1.5,0,0))
elseif surface.Name == "Left" then
PlaceBlock.CFrame = CFrame.new(target.Position + Vector3.new(-1.5,0,0))
elseif surface.Name == "Back" then
PlaceBlock.CFrame = CFrame.new(target.Position + Vector3.new(0,0,1.5))
elseif surface.Name == "Front" then
PlaceBlock.CFrame = CFrame.new(target.Position + Vector3.new(0,0,-1.5))
end
end
mouse.Move:Connect(function()
if placing == true then
local target, surface = mouse.Target, mouse.TargetSurface
if target and (target.Name == "Cannotdelete" or target.Name == "Block") then
placeBlock(target, surface)
else
PlaceBlock:Destroy()
end
end
end)
tool.Equipped:Connect(function()
placing = false
if PlaceBlock.Parent == workspace then
PlaceBlock:Destroy()
end
end)
tool.Unequipped:Connect(function()
placing = false
if PlaceBlock.Parent == workspace then
PlaceBlock:Destroy()
end
end)

6 comments
WHAT IS THIS SPAGHETTI CODE
ascii art on coding wtf
is the "placing" variable ever set to true?
i recommend using elseif so it looks a bit neater lol
I edited the script but it gives me an error that says:
MouseEnter is not a valid member of Part "Players.PreviousSchmuck.Backpack.PlaceBlock.Handle" - Client - LocalScript:14