I am making a door opening system, but the touched event is only firing if I jump. What could cause this problem?
Server Script
local distanceModule = require(game.ServerScriptService.doorHandlers.getDistance)
local doorFolder = game.Workspace.castleDoors
local collectionService = game:GetService("CollectionService")
local currentTag = 1
for _, model in ipairs(doorFolder:GetChildren()) do
collectionService:AddTag(model.Union, "doorUnions")
currentTag += 1
end
for _, part in pairs(collectionService:GetTagged("doorUnions")) do
part.Touched:Connect(function(hit: Part)
local character = hit.Parent
if character then
local player = game.Players:GetPlayerFromCharacter(character)
if not player then return end
local result = distanceModule:getPlayerDistance(player, part)
if result == true then
part.CanCollide = false
end
end
end)
end
Module Script
local module = {}
function module:getPlayerDistance(player: Player, doorModel)
local playerCharacter = player.Character or player.CharacterAdded:Wait()
if playerCharacter then
if (Vector3.new(doorModel.CFrame.X, doorModel.CFrame.Y, doorModel.CFrame.Z) - Vector3.new(playerCharacter.HumanoidRootPart.CFrame.X,playerCharacter.HumanoidRootPart.CFrame.Y,playerCharacter.HumanoidRootPart.CFrame.Z)).Magnitude <= 3 then
return true
else
return false
end
end
end
return module
I’ve recorded a Medal clip, you can find it here.
Doors Location(s)
Thanks in advance!
XV4BT3