Hello there!
I have made a sliding door using PrismaticConstraints. Normally, the door works perfectly. I had a problem with Collisions since the door could collide with everything and couldn’t open properly.
I have made it to not collide with the default group but with the players. I made it not collide with the default group and I created a special collision group for players.
ServerScriptService Script:
local PhysicsService = game:GetSerive("PhysicsService")
PhysicsService:CreateCollisionGroup("Door")
PhysicsService:CreateCollisionGroup("Player")
PhysicsService:CollisionGroupSetCollidable("Door", "Door", false)
PhysicsService:CollisionGroupSetCollidable("Door", "Default", false)
PhysicsService:CollisionGroupSetCollidable("Door", "Player", true)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
for _, v in pairs(character:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
PhysicsService:SetPartCollisionGroup(v, "Player")
end
end
end)
end)
Besides the keycard scanners, the door has a remote opener, which is a Tool. The door has a RemoteEvent in it. When fired, the door will open.
After I made it to not collide with the default group, and I tried to open it with the remote, the RemoteEvent was never fired. After I made it collide with the default group again, the RemoteEvent was fired.
Here is the Remote Tool LocalScript:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local UserInputService = game:GetService("UserInputService")
local Equipped = false
local Connection;
local Connection2;
function Check(tofire)
if Mouse.Target:FindFirstChild("RemoteEvent") then
Mouse.Target.RemoteEvent:FireServer(tofire)
elseif
Mouse.Target.Parent:FindFirstChild("RemoteEvent") then
Mouse.Target.Parent.RemoteEvent:FireServer(tofire)
elseif
Mouse.Target.Parent.Parent:FindFirstChild("RemoteEvent") then
Mouse.Target.Parent.Parent.RemoteEvent:FireServer(tofire)
elseif
Mouse.Target.Parent.Parent.Parent:FindFirstChild("RemoteEvent") then
Mouse.Target.Parent.Parent.Parent.RemoteEvent:FireServer(tofire)
elseif
Mouse.Target.Parent.Parent.Parent.Parent:FindFirstChild("RemoteEvent") then
Mouse.Target.Parent.Parent.Parent.Parent.RemoteEvent:FireServer(tofire)
elseif
Mouse.Target.Parent.Parent.Parent.Parent.Parent:FindFirstChild("RemoteEvent") then
Mouse.Target.Parent.Parent.Parent.Parent.Parent.RemoteEvent:FireServer(tofire)
end
end
script.Parent.Equipped:Connect(function()
Connection = Mouse.Button1Down:Connect(function()
local S, E = pcall(function()
Check("ToggleDoor")
end)
end)
Connection2 = Mouse.Button2Down:Connect(function()
local S, E = pcall(function()
Check("ToggleLockdownStatus")
end)
end)
end)
script.Parent.Unequipped:Connect(function()
Connection:Disconnect()
Connection2:Disconnect()
Connection = nil
Connection2 = nil
end)
CONCLUSION: If the door’s collision group can not collide with the Default one and I click with the remote on the door, it will not work. Else, if the door’s collision group can collide with the Default one and I click with the remote on the door, it will fire the RemoteEvent located within the door.
My concern is what is causing this issue and how I should fix it?