- What do you want to achieve? Keep it simple and clear!
- I want to make it so whenever i pick up an object, it positions it infront of the camera but instead of that it positions it INSIDE the camera and not 1.5 studs away
- What is the issue? Include screenshots / videos if possible!
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
- Yes i didn’t find any.
///
Here’s my code.
local Player = game.Players:GetPlayerFromCharacter(script.Parent)
local Character = script.Parent
local UIS = game:GetService("UserInputService")
local Mouse = Player:GetMouse()
local TweenService = game:GetService("TweenService")
local ServiceInfos = {
FoodInfo = TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
}
local Dropped = false
local Select = false
local Object = nil
Mouse.Move:Connect(function()
pcall(function()
if Mouse.Target:GetAttribute("Food") and Select == false then
local GetDistance = (Character.HumanoidRootPart.Position - Mouse.Target.Position).Magnitude
if GetDistance < 10 then
script.Highlight.Enabled = true
script.Highlight.Adornee = Mouse.Target
elseif GetDistance > 10 then
script.Highlight.Enabled = false
script.Highlight.Adornee = nil
end
elseif Mouse.Target == nil or not Mouse.Target:GetAttribute("Food") then
script.Highlight.Enabled = false
script.Highlight.Adornee = nil
end
end)
end)
Mouse.Button1Up:Connect(function()
if Mouse.Target:GetAttribute("Food") and Select == false then
Object = Mouse.Target
Select = true
repeat wait()
TweenService:Create(Object, ServiceInfos.FoodInfo, {CFrame = workspace.CurrentCamera.CFrame}):Play()
until Dropped == true
Object = nil
Dropped = false
end
end)
UIS.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Q and Dropped == false then
Dropped = true
Select = false
end
end)