WeldingConstraint Issue

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

so there is a problem in my carry system. When i drop the plank , the physic of it works incorrectly

  1. What is the issue? Include screenshots / videos if possible!

To solve that , i read that I should delete the weldconstraint on both , server and client. But when I did that , It just teleports the plank to it initial position

local Obby = workspace:WaitForChild("Obby")
local Sewers = Obby:WaitForChild("Sewers")
local TakePlanks = Sewers:WaitForChild("TakePlanks")
local UIS = game:GetService("UserInputService")

local clickpart = TakePlanks:WaitForChild("ClickPart")
local detector = clickpart:WaitForChild("ClickDetector")

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")

local carriedPlank = nil  

detector.MouseClick:Connect(function()
	print("qwerty")
	for i, plank in ipairs(TakePlanks:GetChildren()) do
		if plank.Name == "Plank" and not plank:FindFirstChild("Weld") then

			char:SetAttribute("Carrying", true)
			carriedPlank = plank  

			local weldo = plank:WaitForChild("weldo")

			weldo.Anchored = false
			plank.CanCollide = false


			local weld = Instance.new("Weld")
			weld.Name = "PlankWeld" 
			weld.Part0 = hrp
			weld.Part1 = weldo
			weld.Parent = hrp

			plank.Parent = char

			plank.Massless = true
			weldo.Massless = true



			break
		end
	end
end)

UIS.InputBegan:Connect(function(input, chat)
	if not chat then
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			if char:GetAttribute("Carrying") and carriedPlank then
				local weld = hrp:FindFirstChild("PlankWeld")
				if weld then
					weld:Destroy()  
				end


				carriedPlank.Anchored = false
				carriedPlank.Massless = false

				carriedPlank.Parent = workspace

				char:SetAttribute("Carrying", false)
				carriedPlank = nil
			end
		end
	end
end)

3 Likes

You could add a function that runs when you drop the plank that updates the cframe

something like this

local CF = plank.CFrame
Weld:Destroy()
plank.CFrame = CF
UIS.InputBegan:Connect(function(input, chat)
	if not chat then
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			if char:GetAttribute("Carrying") and carriedPlank then
                local CF = carriedPlank.CFrame
				local weld = hrp:FindFirstChild("PlankWeld")
				if weld then
					weld:Destroy()  
				end


				carriedPlank.Anchored = false
				carriedPlank.Massless = false
                carriedPlank.CFrame = CF

				carriedPlank.Parent = workspace

				char:SetAttribute("Carrying", false)
				carriedPlank = nil
			end
		end
	end
end)
2 Likes

That doesnt solve the issue. Still teleports it.
Here’s code
Client Side

local Obby = workspace:WaitForChild("Obby")
local Sewers = Obby:WaitForChild("Sewers")
local TakePlanks = Sewers:WaitForChild("TakePlanks")
local UIS = game:GetService("UserInputService")

local clickpart = TakePlanks:WaitForChild("ClickPart")
local detector = clickpart:WaitForChild("ClickDetector")

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart")

local carriedPlank = nil  

detector.MouseClick:Connect(function()
	print("qwerty")
	for i, plank in ipairs(TakePlanks:GetChildren()) do
		if plank.Name == "Plank" and not plank:FindFirstChild("Weld") then

			char:SetAttribute("Carrying", true)
			carriedPlank = plank  

			local weldo = plank:WaitForChild("weldo")

			weldo.Anchored = false
			plank.CanCollide = false


			local weld = Instance.new("Weld")
			weld.Name = "PlankWeld" 
			weld.Part0 = hrp
			weld.Part1 = weldo
			weld.Parent = hrp

			plank.Parent = char

			plank.Massless = true
			weldo.Massless = true



			break
		end
	end
end)

UIS.InputBegan:Connect(function(input, chat)
	if not chat then
		if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
			if char:GetAttribute("Carrying") and carriedPlank then
				local weld = hrp:FindFirstChild("PlankWeld")
				if weld then
					weld:Destroy()  
				end


				carriedPlank.Anchored = false
				carriedPlank.Massless = false

				carriedPlank.Parent = workspace

				char:SetAttribute("Carrying", false)
				carriedPlank = nil
			end
		end
	end
end)

ServerSide

game.ReplicatedStorage.DeleteWeld.OnServerEvent:Connect(function(player, plank)
	plank:FindFirstChild("WeldConstraint"):Destroy()
end)
1 Like

you must pass the CF of the plank to the remote event

something like this

DestroyWeld:FireServer(plank, plank.CFrame)

and now on serverside

game.ReplicatedStorage.DeleteWeld.OnServerEvent:Connect(function(player, plank, CF)
   plank:FindFirstChild("WeldConstraint"):Destroy()
   plank.CFrame = CF
end

try this

2 Likes

Omg thank you so much bro ive been messing with it for like 3-4 hours

1 Like

One question. How can i make so CF changes only on client?I mean it works fine , but other players can see and walk on planks . I need it to be on client only.

Make the weld on client side. Don’t do it on the server as the server replicates to all clients
what you make on local scripts stays local (on your client only) with a bit of a caveat here; that is when talking about your character

the rest of the script should stay the same, don’t think it will affect

1 Like

Is there any other ways to delete weld on client and make physics properly work?

You could simulate a weld with CFrames, but you don’t seem to want to do that.
Do you need the weld to pe on the server?

Hey, i’ve got an idea
Collision groups

  • A: you make a collision group for players, and a collision group for planks, make plankCollisionGroup to not collide with the playerCollisionGroup. and you switch between normal and plankCollisionGroup when you pick it up or drop it

or

  • B: you make the plank nonCollidable when you pick it up

Thanks . I’ll try that and then reply

Here’s the video of the problem if this somehow helps to find more solutions

1 Like

So I found new solution . I’ll just destroy current plank when dropping it and then i’ll clone plank model from replicated storage and parent it to workspace. Thank you for helping me though!

1 Like

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