Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Placing script moves the object but the object is not all the way above the ground or base?

GIF of moving: Moving

Pic Of Object: Object

Script:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(0.5)
local Rs = game:GetService("RunService")
local Hb = Rs.Heartbeat

function getBaseFromPlayer(Player)
	for i,v in pairs(workspace.Bases:GetChildren()) do
		local Info = v.Info
		local Owner = Info.Owner
		if Owner.Value ==  Player then
			return v
		end
	end
end

function MoveObj(Position, Obj)
	Obj:SetPrimaryPartCFrame(CFrame.new(Position.X, 1, Position.Z))
end

function StartPlacing(Obj)
	local ObjClone = Obj:Clone()
	ObjClone.Parent = workspace.CurrentCamera
	for i,v in pairs(ObjClone:GetChildren()) do
		if v:IsA("BasePart") and v.Name ~= "Hitbox" then
			v.Transparency = 0.5
			v.CanCollide = false
		end
	end
	return ObjClone
end

local Obj = game:GetService("ReplicatedStorage"):WaitForChild("Items").TestModel
local PlacingItem = StartPlacing(Obj)
Hb:Connect(function()
	MoveObj(Mouse.hit.p, PlacingItem)
end)

1 answer

The problem is probably that the mouse doesn't ignore the object you're trying to place. Just add this little snippet of code to your script.

Mouse.TargetFilter = ObjClone

This discussion is preserved as it was. New answers, comments, and votes are closed.