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

Dragging Blocks or Models?

Asked by 8 years ago

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)

0
I believe gameProcessedEvent is `true` if the input is successful. Do `gpe` instead of `not gpe`. XAXA 1569 — 8y
0
You have to set the primary part beforr using the method SetPrimaryPartCFrame Wutras 294 — 8y

1 answer

Log in to vote
-2
Answered by 8 years ago

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

0
Hehe sorry about that! How can i check if it has a primary part? iRicky6s 0 — 8y
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. AsyncsAlt 0 — 8y
0
Okay so i added the primary part, but it still doesn't work :/ iRicky6s 0 — 8y
Ad

Answer this question