You can write your topic however you want, but you need to answer these questions:
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
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)
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)
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)
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
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
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!