The whole of the script works except the part which finds the character. I have searched the internet but I cannot find what I need.
Here is the script:
local ps = game:GetService("PhysicsService")
ps:CreateCollisionGroup("fiftyPointdoor")
ps:CreateCollisionGroup("50Pointplayer")
local fiftyPdoor = game.Workspace.fiftyPdoor
local function SetColGroupDoors(door, group)
ps:SetPartCollisionGroup(door, group)
end
SetColGroupDoors(fiftyPdoor, "fiftyPointdoor")
local function SetColGroupPlr(char, group)
for i, child in ipairs(char:GetChildren()) do
if child:IsA("BasePart") then
ps:SetPartCollisionGroup(child, group)
end
end
char.DescendantAdded:Connect(function(desc)
if desc:IsA("BasePart") then
ps:SetPartCollisionGroup(desc, group)
end
end)
end
game.Players.PlayerAdded:Connect(function(plr)--Error somewhere here
plr.CharacterAdded:Connect(function(char)
while true do
wait(1)
if plr.leaderstats.Points.Value >= 50 then
SetColGroupPlr(char, "50Pointplayer")
end
end
end)
end)
ps:CollisionGroupSetCollidable("fiftyPointdoor", "50Pointplayer", false)
What environment is changing the value of Points? In the client or server?
And while I assume this is a server-side script, Iβd like to be sure. What is the class name/script context of this script?
You mean you are running this script in command bar? Or that you are increasing the points of yours from command bar?
If you increase the points in command bar client side, then that value will never change on server side, go to server side in your simulation and increase the points from there, but. Even if you increase the points there, your script wont do nothing cause it will only fire when player joins. So if a player already joined and you change the points after the join your script will do nothing
I think we have a misunderstanding. Your while loop probably is correctly checking the value if exist, otherwise you would see a error.
But if you are changing the value from client side your while loop will never find that the points are higher or equal to 50 so, it will never call to SetColGroupPlr()
Add a print on that function to see if that function is at least called
I mean what is the behavior you expect to happen?
In that function you are asking parts of the player be added to a collision group.
You dont see the parts added into that Collision group? or what is the sympthom?
So you said the function got called correctly, you added prints to see that each part of the player got added during the for loop?
You actually did check the collision group tab to see what parts are in it?
Perhaps the door is not even in that collision group, but if you check whats into that collision group you would find a reason why its not working