Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my placement system acting weird?

Asked by 3 years ago

So im making a placement system right now and something weird is happening the code and a short vid are below

wait()
local plan = game.ReplicatedStorage.Floor.Selection
local build = game.ReplicatedStorage.Floor.floor
local pos = Vector3.new(0,0,0)
script.Parent.Equipped:Connect(function(mouse)
    local plan1 = plan:Clone()
    plan1.Parent = game.Workspace
    mouse.Button1Down:connect(function()
        print("ok")
        local build1 = build:Clone()
        build1.Parent = game.Workspace
        build1.Position = plan1.Position
    end)
    while wait() do
        pos = Vector3.new(math.floor(mouse.Hit.p.X),math.floor(mouse.Hit.p.Y),math.floor(mouse.Hit.p.Z))
        plan1.Position = pos+Vector3.new(0,0,0)
    end
end)

https://medal.tv/clips/33015914/d13373Haqm99 can anyone help me solve this issue?

0
it looks like the Mouse.hit is hitting the thing your moving causing the "getting closer" bug. Might be worth offsetting the placement for the thing your moving with the mouse so the mouse.hit only hits the thing your trying to build and not the part your moving. TGazza 1336 — 3y

1 answer

Log in to vote
0
Answered by
tomekcz 174
3 years ago

Like TGazza said its hitting the same thing your moving however offset isnt the best way to resolve this i would recommend reading this https://developer.roblox.com/en-us/api-reference/property/Mouse/TargetFilter

Ad

Answer this question