Hello so, I was making my own placement system but I’ve came up in-front of a problem with the object movement. The Y axis works smooth and the CFrame is perfectly not set. Here’s my code:
local mouse = game.Players.LocalPlayer:GetMouse()
local Grid = 4
script.Parent.MouseButton1Click:Connect(function() -- The button
if game.ReplicatedStorage.ObjectsFolder:FindFirstChild(script.Parent.Text) then
local foundObject = game.ReplicatedStorage.ObjectsFolder:FindFirstChild(script.Parent.Text)
script.Parent.Parent.CurrentObject.Value = foundObject.Name -- Value inside of ScreenGui
print(foundObject.Name .. " is now active!")
local cloneOfFoundObject = foundObject:Clone()
cloneOfFoundObject.Parent = game.Workspace
print(cloneOfFoundObject.Parent.Name .. " is the parent of " .. cloneOfFoundObject.Name .. "!")
end
end)
mouse.Move:Connect(function()
if game.Workspace:FindFirstChild(script.Parent.Parent.CurrentObject.Value) then
local foundObjectInWorkspace = game.Workspace:FindFirstChild(script.Parent.Parent.CurrentObject.Value)
foundObjectInWorkspace:SetPrimaryPartCFrame(CFrame.new(math.floor((mouse.Hit.X + Grid / 2) / Grid) * Grid, mouse.Hit.Y + 2, math.floor((mouse.Hit.Z + Grid / 2) / Grid) * Grid))
mouse.TargetFilter = foundObjectInWorkspace
end
end)
Any help would help a lot! Thanks!
- AridFights1