Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Dragging Blocks or Models?

How can I allow a player to drag certain models like in the style of Lumber Tycoon 2?

Some suggested this code but It doesn't give errors, and doesn't seem to work.

local model = workspace.TestModel


local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

UIS.InputBegan:connect(function(input, gpe)
if not gpe and input.UserInputType == Enum.UserInputType.MouseButton1 then
model:SetPrimaryPartCframe(CFrame.new(Mouse.hit.x, Mouse.hit.y, Mouse.hit.z))
end
end)

2 comments

0

I believe gameProcessedEvent is true if the input is successful. Do gpe instead of not gpe.

0

You have to set the primary part beforr using the method SetPrimaryPartCFrame

1 answer

When you post next time, hit the lua logo, so its easier for us to read, check if it has a primary part?

3 comments

0

Hehe sorry about that! How can i check if it has a primary part?

0

In studio, you can actually make a part of a model a primary part. All you have to do is : Use the tool, or the basepart script thing.

0

Okay so i added the primary part, but it still doesn't work :/

This discussion is preserved as it was. New answers, comments, and votes are closed.