If you wanna see-able for other players w/ keybinding included but you have to make it so it inserts a sphere in
Keybindable Code: local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local target
local down
local Keybind = "E"
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode[Keybind] then
if mouse.Target.Name == "Grab" then
if mouse.Target ~= nil and mouse.Target.Locked == false then
target = mouse.Target
mouse.TargetFilter = target
down = true
target.CanCollide = false
target.Anchored = false
local gyro = Instance.new("BodyGyro")
gyro.Name = "Gyro"
gyro.Parent = target
gyro.MaxTorque = Vector3.new(5000000, 5000000, 5000000)
local force = Instance.new("BodyPosition")
force.Name = "Force"
force.Parent = target
force.MaxForce = Vector3.new(100000000000, 100000000000, 100000000000)
end
end
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if down == true and target ~= nil then
target.Gyro.CFrame = target.CFrame
target.Force.Position = camera.CFrame.Position + (mouse.UnitRay.Direction * 5)
end
end)
game:GetService("UserInputService").InputEnded:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode[Keybind] then
if target then
if target:FindFirstChild("Gyro") or target:FindFirstChild("Force") then
target.Gyro:Destroy()
target.Force:Destroy()
target.CanCollide = true
target.Anchored = false
end
end
down = false
mouse.TargetFilter = nil
target = nil
end
end)
NonKeybindable Code: local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local target
local down
mouse.Button1Down:connect(function()
if mouse.Target.Name == "Grab" then
if mouse.Target ~= nil and mouse.Target.Locked == false then
target = mouse.Target
mouse.TargetFilter = target
down = true
target.CanCollide = false
target.Anchored = false
local gyro = Instance.new("BodyGyro")
gyro.Name = "Gyro"
gyro.Parent = target
gyro.MaxTorque = Vector3.new(5000000, 5000000, 5000000)
local force = Instance.new("BodyPosition")
force.Name = "Force"
force.Parent = target
force.MaxForce = Vector3.new(100000000000, 100000000000, 100000000000)
end
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if down == true and target ~= nil then
target.Gyro.CFrame = target.CFrame
target.Force.Position = camera.CFrame.Position + (mouse.UnitRay.Direction * 5)
end
end)
mouse.Button1Up:connect(function()
if target then
if target:FindFirstChild("Gyro") or target:FindFirstChild("Force") then
target.Gyro:Destroy()
target.Force:Destroy()
target.CanCollide = true
target.Anchored = false
end
end
down = false
mouse.TargetFilter = nil
target = nil
end)
6 comments
We don't understand. I've never played Lumber Tycoon and I don't feel like playing a game just to fix your problem, do you have a better explanation?
It's literally been front page for about 4 months but anyways, say you chop down a tree. You can then drag it into your truck it kinda floats and follows the mouse. But if you move the mouse too fast or the piece of wood is too heavy it will drop. Hopefully that is a better explanation.
I'm not sure about your level of experience in coding but I'm gonna say that you probably don't have nearly enough experience to make something like this. Though like I said. I'm not sure what your experience level really is.
I could probably do it with weeks of trial and error and ive created a similar system within a couple of days. But i really wanna ace it and get it down to the last detail. I can script it if i just have an idea on where to start and what methodologies to use.
This was what I was trying to ask about the other day... Haha.
You notice that when you click on whatever thing, a very small tiny sphere appears at the mouse position of where you clicked it.