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!
Apply new collisiongroup to players near instantly so they don’t collide with each other. -
What is the issue? Include screenshots / videos if possible!
Without a wait() delay of around 3 seconds the new collision groups don’t load and can’t be seen in the explorer (the collisions are supposed to be applied in a server script). -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Not really a solution, but I’ve tried printing the collisiongroup of each characters’ children parts but they actually contradict the explorer and suggest all are part of the collisiongroup that I’m trying to set them to.
“hasProperty” is a custom “hacky” function that finds the properties so the code doesn’t break with an error but the problem still applies without it.
Not a major issue as a 3 second delay shouldn’t hugely impact regular gameplay but its bloody annoying and I have to sleep at some point. Thanks in advance!
function NoCollide(model)
for k,v in pairs(model:GetChildren()) do
if v:IsA("BasePart") then
v.CollisionGroup = "p"
end
end
end
function hasProperty(object, propertyName) --"hacky" function for debugging only
local success, _ = pcall(function()
object[propertyName] = object[propertyName]
end)
return success
end
function.Event:Connect(function()
print("collision function running")
for i, player in pairs(game.Teams.Innocents:GetPlayers()) do
local char = player.Character
char:WaitForChild("HumanoidRootPart")
char:WaitForChild("Head")
char:WaitForChild("Humanoid")
NoCollide(char)
for i,v in pairs(char:GetChildren()) do
if hasProperty(v,"CollisionGroup") then
print(v.CollisionGroup)
end
end
--wait(1)
--NoCollide(char)
--for i,v in pairs(char:GetChildren()) do
-- if hasProperty(v,"CollisionGroup") then
-- print(v.CollisionGroup)
-- end
--end
--wait(1)
--NoCollide(char)
--for i,v in pairs(char:GetChildren()) do
-- if hasProperty(v,"CollisionGroup") then
-- print(v.CollisionGroup)
-- end
--end
--wait(1)
--NoCollide(char)
end
end)