Weld Issue, Weld Doesn't destroy

I am making a train, game where I welded the players to the ground for short moment when they get out of their seats so as to not fling them while the train is in motion.

The Issue: The weld is not destroying after the 1 second wait at the end

	print(Hit.Name)

	local NewWeld = Instance.new("Weld")
	
	NewWeld.C0 = Hit.CFrame:toObjectSpace(RootPart.CFrame)
	NewWeld.C1 = CFrame.new()
	
	NewWeld.Parent = Hit
	NewWeld.Part0 = Hit
	NewWeld.Part1 = RootPart

	wait(1)

	NewWeld:Destroy()
	NewWeld = nil

I tried to destroy the weld after 1 second but the player still remains stuck above their seat. How do i fix this?

This is the rest of the seat. The weld is made after .Seated

Also notice the Print Name, it is suppose to fire only when the player seats and stands. So far, its keeps on printing when the players gets stuck

wait(4)
local PlayerModel = script.Parent
local Humanoid = PlayerModel:WaitForChild("Humanoid")

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude

Humanoid.Seated:Connect(function()


	local RootPart = PlayerModel:WaitForChild("RightFoot")
	local Ignore = { PlayerModel }

	for _, part in game.workspace:GetDescendants() do
		if part.Name ~= "TrainFloor" and part.Parent.Name ~= "Workspace" then
			table.insert(Ignore, part)
		end
	end

	raycastParams.FilterDescendantsInstances = Ignore

	local result = workspace:Raycast(RootPart.CFrame.p, Vector3.new(0, -500, 0), raycastParams)
	if not result then
		return --nothing below the character
	end

	local Hit, Position, Normal, Material = result.Instance, result.Position, result.Normal, result.Material

	--------------------------------
	print(Hit.Name)

	local NewWeld = Instance.new("Weld")
	
	NewWeld.C0 = Hit.CFrame:toObjectSpace(RootPart.CFrame)
	NewWeld.C1 = CFrame.new()
	
	NewWeld.Parent = Hit
	NewWeld.Part0 = Hit
	NewWeld.Part1 = RootPart

	wait(1)

	NewWeld:Destroy()
	NewWeld = nil

end)
3 Likes

Instead of destroying it try disabling it.

1 Like

what do you mean by disabling it

1 Like

It a boolean property.
NewWeld.Enabled = false

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.