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

Object expands on dragging -why?

Asked by 8 years ago

here is my code

local Fruittilium = game.Workspace.Fruittilium
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local down = false
Mouse.Button1Down:connect(function()
    down = true
    if Mouse.Target == Fruittilium then
    local Fruit = Fruittilium:Clone()
    Fruit.Parent = game.Workspace
    Fruit.Name = "ACOFruit"
    Fruit.Anchored = true
 while true do
    Fruit.Position = Vector3.new(Mouse.hit.p.x, Mouse.hit.p.y, Mouse.hit.p.z)
    if down == false then
    Fruit:Destroy()
    break
end
    wait(.01)
    end
    else print(Mouse.hit.p)
end
end)
Mouse.Button1Up:connect(function()
    down = false
end)

whenever I clicked on the fruit I would be able to drag a copy of it... the problem is that the clone of the fruit is expanding an then pops..... like a balloon and every time I move it, it reverts to its original size... only to expand and pop again

1 answer

Log in to vote
0
Answered by 8 years ago

It's actually not expanding. Rather, it's moving closer and closer to your camera until it goes behind it (what you see as popping).

A simple fix is to set Mouse.TargetFilter = Fruittilium after you check if Mouse.Target == Fruittilium. Then, after the while loop finishes, reset it to Mouse.TargetFilter = nil.

Ad

Answer this question