Hi so I’ve been stuck on this problem for hours and everything i’ve tried so far didn’t work
*Changed the collision group name
*chaged the networkownership
*tried creating the col. groups via. script
I have no clue pls. help
ServerScriptService:
----------------------------------/varibles/
local dolltemplate = game.ServerStorage.Serverasstes.dollpreset
--------------------------------------------/functions/
function createnewdoll(player)
local playerdoll = dolltemplate:Clone()
playerdoll.Parent = workspace.dolls
for i , part in ipairs(playerdoll:GetDescendants()) do
if part:IsA("MeshPart") then
part.CollisionGroup = "Dolls"
end
end
playerdoll.Head:SetNetworkOwner(player)
return playerdoll
end
--------------------------------------------/classes/
-----
--------------------------------------------/Setupddollfunc/
game.ReplicatedStorage.setupdoll.OnServerInvoke = function(player)
if workspace.dolls:FindFirstChild(player.Name) then
workspace.dolls:FindFirstChild(player.Name):Destroy()
end
for i , bodypart in ipairs(game.Players:FindFirstChild(player.Name).Character:GetChildren()) do
if bodypart:IsA("Part") then
bodypart.CollisionGroup = "Players"
bodypart.Transparency = 1
if bodypart:FindFirstChildOfClass("Decal") then
bodypart:FindFirstChildOfClass("Decal"):Destroy()
end
end
if bodypart:IsA("Accessory") then
bodypart:Destroy()
end
end
local playerdoll = createnewdoll(player)
end
Client script under starter char.:
local lp = game.Players.LocalPlayer
local char = lp.Character
local dolls = workspace.dolls
local doll
---------------------------------------/initialize/
while doll == nil do
game.ReplicatedStorage.setupdoll:InvokeServer()
doll = workspace.dolls:FindFirstChild(lp.Name)
end
for i , part in ipairs(doll:GetDescendants()) do
if part:IsA("MeshPart") then
part.CollisionGroup = "Dolls"
end
end
for i , bodypart in ipairs(char:GetChildren()) do
if bodypart:IsA("Part") then
bodypart.CollisionGroup = "Players"
end
end
end)
It keeps bugging out and the character colides with the other character
local lp = game.Players.LocalPlayer
local char = lp.Character
local dolls = workspace.dolls
local doll
---------------------------------------/initialize/
while doll == nil do
game.ReplicatedStorage.setupdoll:InvokeServer()
doll = workspace.dolls:FindFirstChild(lp.Name)
end
for i , part in ipairs(doll:GetDescendants()) do
if part:IsA("MeshPart") then
part.CollisionGroup = "Dolls"
local alignpos = Instance.new("AlignPosition")
alignpos.Parent = part
alignpos.Name = part.Name.."muscle"
alignpos.Mode = Enum.PositionAlignmentMode.OneAttachment
alignpos.Attachment0 = part:FindFirstChildOfClass("Attachment")
alignpos.RigidityEnabled = true
alignpos.ApplyAtCenterOfMass = true
alignpos.Position = char:FindFirstChild(part.Name).CFrame.Position
char:FindFirstChild(part.Name).Changed:Connect(function(value)
end)
end
end
for i , bodypart in ipairs(char:GetChildren()) do
if bodypart:IsA("Part") then
bodypart.CollisionGroup = "Players"
end
end
game:GetService("RunService").PreSimulation:Connect(function()
for i , constraint in ipairs(doll:GetDescendants()) do
if constraint:IsA("AlignPosition") then
local part = constraint.Parent
if constraint then
constraint.Position = char:FindFirstChild(part.Name).CFrame.Position
end
end
end
end)
Server
----------------------------------/varibles/
local dolltemplate = game.ServerStorage.Serverasstes.dollpreset
--------------------------------------------/functions/
function createnewdoll(player)
local playerdoll = dolltemplate:Clone()
playerdoll.Name = player.Name
for i , constraint in ipairs(playerdoll:GetDescendants()) do
if constraint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
socket.Name = constraint.Name.."-ballsocket"
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Name = "a1"
a2.Name = "a2"
a1.Parent = constraint.Part0
a2.Parent = constraint.Part1
socket.Parent = constraint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = constraint.C0
a2.CFrame = constraint.C1
constraint.Enabled = false
if constraint.Name == "Neck" then
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
else
socket.TwistLimitsEnabled = false
socket.LimitsEnabled = false
end
constraint.Part1.CanCollide = true
constraint:Destroy()
end
if constraint:IsA("MeshPart") then
constraint.CanCollide = false
end
end
playerdoll.Parent = workspace.dolls
for i , part in ipairs(playerdoll:GetDescendants()) do
if part:IsA("MeshPart") then
part.CollisionGroup = "Dolls"
end
end
playerdoll.Head:SetNetworkOwner(player)
return playerdoll
end
--------------------------------------------/classes/
-----
--------------------------------------------/Setupddollfunc/
game.ReplicatedStorage.setupdoll.OnServerInvoke = function(player)
if workspace.dolls:FindFirstChild(player.Name) then
workspace.dolls:FindFirstChild(player.Name):Destroy()
end
for i , bodypart in ipairs(game.Players:FindFirstChild(player.Name).Character:GetChildren()) do
if bodypart:IsA("Part") then
bodypart.CollisionGroup = "Players"
bodypart.Transparency = 1
if bodypart:FindFirstChildOfClass("Decal") then
bodypart:FindFirstChildOfClass("Decal"):Destroy()
end
end
if bodypart:IsA("Accessory") then
bodypart:Destroy()
end
end
local playerdoll = createnewdoll(player)
end
local ps = game:GetService("PhysicsService")
ps:RegisterCollisionGroup("Dolls")
ps:RegisterCollisionGroup("Players")
ps:CollisionGroupSetCollidable("Dolls", "Players", false)
game.Player.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
for _, part in pairs(char:GetChildren()) do
if part:IsA("BasePart") then
part.CollisionGroup = "Players"
end
end
end)
end)
It already sets the colision group of the player when respawning because its done while the setup of the ragdoll which runs when the player spawns (I even checked it)