I am currently trying to add console-compatibility to my game however, to do so i need to find out which item the player’s cursor (on console) is on.
I have this so far for the console compatible controls:
userinputservice.InputBegan:Connect(function(input, gameprocessedevent)
if input.KeyCode == Enum.KeyCode.ButtonR2 then
if mouse.Target and mouse.Target.Parent:IsA("Model") and mouse.Target.Parent:FindFirstChild("Grabbable") then
if not game.Players:FindFirstChild(mouse.Target.Parent.Name) and not mouse.Target.Parent.PrimaryPart:FindFirstChild("IsGrabbed") then
grabbing = true
grabbeditem = mouse.Target.Parent.PrimaryPart
_G.Item = grabbeditem
game.ReplicatedStorage.ItemGrabbed:FireServer(grabbeditem)
local bp = Instance.new("BodyPosition", grabbeditem)
bp.D = 150
bp.P = 2000
grabbeditem.Parent.Outline.Transparency = 0
end
end
elseif input.KeyCode == Enum.KeyCode.ButtonL2 then
if grabbing == true then
facing = true
end
end
end)
userinputservice.InputEnded:Connect(function(input, gameprocessedevent)
if input.KeyCode == Enum.KeyCode.ButtonR2 then
grabbing = false
facing = false
if grabbeditem and grabbeditem:FindFirstChild("BodyPosition") then
game.ReplicatedStorage.ItemReleased:FireServer(grabbeditem, false)
grabbeditem.Parent.Outline.Transparency = 1
grabbeditem.BodyPosition:Destroy()
end
if grabbeditem and grabbeditem:FindFirstChild("BodyGyro") then
grabbeditem.BodyGyro:Destroy()
end
_G.Item = nil
elseif input.KeyCode == Enum.KeyCode.ButtonL2 then
facing = false
grabbing = false
if grabbeditem and grabbeditem:FindFirstChild("BodyPosition") then
grabbeditem.Parent.Outline.Transparency = 1
grabbeditem.BodyPosition:Destroy()
grabbeditem.Velocity = camera.CFrame.LookVector * 150
game.ReplicatedStorage.ItemReleased:FireServer(grabbeditem)
end
if grabbeditem and grabbeditem:FindFirstChild("BodyGyro") then
grabbeditem.BodyGyro:Destroy()
end
_G.Item = nil
end
end)
The “Mouse.Target” Is what i’m not sure will work and am trying to change.