Hey guys.
So, I’ve tried twice to make a Placement System based on Mouse.Hit. The thing is, every time, it comes closer and closer to the camera before finally stopping and falling to the ground (not what I want).
Here’s my Placement Service module:
local _PS = {}
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local IsBuilding = true
local PreviewModel
function _PS:CreatePreviewModel(item)
local model = game.ReplicatedStorage.Buildables[item]:Clone()
model.Parent = game.Workspace
for _, part in pairs(model:GetChildren()) do
if part:IsA("Part") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
part.BrickColor = BrickColor.new("Bright blue")
part.Transparency = 0.5
end
end
PreviewModel = model
end
function _PS:UpdatePreviewModelCFrame()
if not IsBuilding then return end
if PreviewModel == nil then _PS:CreatePreviewModel("Test") end
print("Updating...")
PreviewModel:SetPrimaryPartCFrame(mouse.Hit)
end
return _PS
and here’s my LocalScript that manages when to update:
local PlacementService = require(game.ReplicatedStorage.Modules.PlacementService)
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local IsBuilding = true
mouse.Move:Connect(function()
if not IsBuilding then return end
PlacementService:UpdatePreviewModelCFrame()
end)
I’ve tried time and time again, but I just can’t get it to work properly.
Thanks!
EDIT: here’s a video of what’s happening.