i have a VR grabbing script and when i play i get no errors but it doesnt work, should i be using remote events for this? also im using nexus VR Module so the VR Player is already scripted.
anyway i can improve this or re-script it to work? any help is appreciated
You need to give more information. What does the script look like?
1 Like
im sorry i knew i was missing something, lol. heres the code
game.Players.PlayerAdded:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local InputService = game:GetService("UserInputService")
local HeadPosition = nil
local function GetTouchingParts(part)
local connection = part.Touched:Connect(function() end)
local results = part:GetTouchingParts()
connection:Disconnect()
local final = {}
for i,x in pairs(results) do if x.Parent ~= part.Parent and not x.Locked then table.insert(final,x) end end
return final
end
local function SearchTable(tab,val,delete)
local Found = false
for i,x in pairs(tab) do
if x == val then
Found = true
if delete then table.remove(tab,i) end
break
end
end
return Found
end
local Holding = {}
local function GrabObject(Part,Input)
spawn(function()
if not SearchTable(Holding,Part,false) then
local eatdb = true
while Input.Position.Z > 0.1 do
local cangrab = Part:FindFirstChild("CanGrab")
if cangrab.Value == true then
Part.CFrame = char.RightHand.CFrame
game:GetService("RunService").RenderStepped:Wait()
end
SearchTable(Holding,Part,true)
end
end
end)
end
local function HandleInput(Input)
if Input.KeyCode == Enum.KeyCode.ButtonR2 then
local Parts = GetTouchingParts(char.RightHand)
for i,x in pairs(Parts) do
print(Parts[1].Name)
GrabObject(x,Input)
end
end
end
InputService.InputChanged:Connect(HandleInput)
end)
i sent the script, idk if you saw it or not. no rush