-
What do you want to achieve? Hello, i found a bug with my elevator system that welds players to the lift to prevent any physics issues.
-
What is the issue? When a player gets killed in it, the player that got killed dies and the player that killed the other dies too, and when they try going back in the elevator they are killed instantly.
This is how the system works, i have a table called PlayersInElevator
each times a player character UpperTorso touch the detection part in the lift, the player is added to the table.
This is how i weld the players to the elevator
for i,v in pairs(PlayersInElevator) do
local player = Players:FindFirstChild(v)
if player then
local character = player.Character
if character.Humanoid.Health > 0 then
if character:FindFirstChild("LowerTorso") then
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Parent = LiftDetectPart
WeldConstraint.Part0 = LiftDetectPart
WeldConstraint.Part1 = character.LowerTorso
character.Humanoid.Died:Once(function()
WeldConstraint.Part1 = nil
WeldConstraint.Enabled = false
WeldConstraint:Destroy()
end)
end
end
end
end
And this is how i remove all the welds
for _, weld in pairs(LiftDetectPart:GetChildren()) do
if weld:IsA("WeldConstraint") then
weld.Part1 = nil
weld.Enabled = false
weld:Destroy()
end
end
- What solutions have you tried so far? I looked on forums and tried to fix it myself.