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 4 years ago

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

01wait()
02local plan = game.ReplicatedStorage.Floor.Selection
03local build = game.ReplicatedStorage.Floor.floor
04local pos = Vector3.new(0,0,0)
05script.Parent.Equipped:Connect(function(mouse)
06    local plan1 = plan:Clone()
07    plan1.Parent = game.Workspace
08    mouse.Button1Down:connect(function()
09        print("ok")
10        local build1 = build:Clone()
11        build1.Parent = game.Workspace
12        build1.Position = plan1.Position
13    end)
14    while wait() do
15        pos = Vector3.new(math.floor(mouse.Hit.p.X),math.floor(mouse.Hit.p.Y),math.floor(mouse.Hit.p.Z))
16        plan1.Position = pos+Vector3.new(0,0,0)
17    end
18end)

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 — 4y

1 answer

Log in to vote
0
Answered by
tomekcz 174
4 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