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

How to make a Draggable Object?

Asked by 8 years ago

Ok, this time I actually tried

local Fruittilium = game.Workspace.Fruittilium
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:connect(function()
    if Mouse.Target == Fruittilium then
    print("you clicked it")
    local Fruit = Fruittilium:Clone()
    Fruit.Parent = game.Workspace
    Fruit.Position = Mouse.Hit 
end
end)

It returned Players.Player1.PlayerScripts.LocalScript:9: bad argument #3 to 'Position' (Vector3 expected, got CFrame) What did I do wrong? can someone help me?

1 answer

Log in to vote
0
Answered by 8 years ago

Hi! So after inspecting your code in a quick proof read, and looking at the Output, I have found your error. Your error is actually quite silly, but common mistake. A simple change in words would fix it!

local Fruittilium = game.Workspace.Fruittilium
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:connect(function()
    if Mouse.Target == Fruittilium then
    print("you clicked it")
    local Fruit = Fruittilium:Clone()
    Fruit.Parent = game.Workspace
    Fruit.CFrame = Mouse.Hit 
end
end)

Basically what your mistake was, was that you tried to position the "Fruit" to the Mouse.Hit, which is a CFrame value. The Position property is a Vector3 value.

Just be careful next time, as this does tend to happen.

Ad

Answer this question