Hello. So I was currently trying to display an items on the screen by positioning it infront of the camera. However, the item’s position would be different for all devices.
local camera = workspace.Camera
script.Parent.MouseButton1Up:Connect(function()
for i,v in pairs(game:GetService("ReplicatedStorage").Tools:GetDescendants()) do
if v.Name == script.Parent.Item.Value and v:IsA("Tool") then
local item = v:Clone()
local handle = item:FindFirstChild("Handle")
item.Parent = camera
--script.Parent.Parent.Parent.Parent.ItemName.Text = item.Name
for i,v in pairs(item:GetDescendants()) do
if v:IsA("BasePart") then
v.CanCollide = false
v.Anchored = true
local scale = 0.25
v.Size = (v.Size * scale)
if (v ~= handle) then
v.CFrame = (handle.CFrame + (handle.CFrame:inverse() * v.Position * scale))
end
end
end
local function hasProperty(object, prop)
local t = object[prop]
end
local success = pcall(function() hasProperty(handle, "MeshId") end)
local r = 1
game:GetService("RunService"):BindToRenderStep("...", Enum.RenderPriority.Camera.Value + 1, function()
handle.CFrame = camera.CFrame * CFrame.new(-2.8, 0, -8) * CFrame.Angles(math.rad(-90),0,0) * CFrame.Angles(0,0,math.rad(r))
r=r+1
if r == 361 then
r = 1
end
end)
end
end
end)
PC:
Mobile: