Okay so i’m creating a VR game (using nexus vr thingy since idk how to create my own ‘multiplayer vr’)
But i’m having a bit of trouble with the sword script.
in vr if the Collision is enabled it can collide with the ground and stuff (obviously) but if u have it in hand and point it at the ground it glitches weirdly.
So i thought of just having CanCollide disabled and making a script that enabled when it sees a specific part. In this case it would be a part named “part” inside a tool.
So i tried putting one tool model of that sword in workspace and one in starterpack for you to equip. But it doesnt seem to work.
pictures and script >>>
local tool = game:GetService("StarterPack"):WaitForChild("Tool") -- Replace with the path to your tool in the StarterPack
local partA = workspace.Sword.Blade -- Replace with the part in the Workspace
local partB = tool.Blade -- Replace with the part in the tool
local function onPartATouched(otherPart)
if otherPart:IsDescendantOf(tool) and otherPart == partB then
-- partA touched partB in the tool
partA.CanCollide = true
partB.CanCollide = true
print("partA touched partB in the tool!")
else
partA.CanCollide = false
partB.CanCollide = false
print("Parts aren't touching")
end
end
-- Connect the Touched event of partA
partA.Touched:Connect(onPartATouched)
I don’t know if this is what you were going for, but instead of using a .touched event to make them collide, why don’t you try a collision group instead?
Make a collision group here, under the “Model” tab:
PhysicsService = game:GetService("PhysicsService")
Tool = script.Parent
-- Assign tool blade to pre-made group
Tool.Blade.CollisionGroup = "Swords"
-- Make it so they can't collide with anything else but each other
PhysicsService:CollisionGroupSetCollidable("Swords","Default", false)
PhysicsService:CollisionGroupSetCollidable("Swords","Swords", true)
If you want to learn more about collision groups, a link to the documentation is here