What do you want to achieve?
I want the accesories have cant touch and cant register propetry
What is the issue? Include screenshots / videos if possible!
Problem is due to accesories not being loaded the script cannot modify it
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried using PlayerAdded, CharacterAdded:Wait()
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
print("Adjusting.." .. plr.Name)
plr.CharacterAdded:Wait()
for _, child in pairs(plr.Character:GetDescendants()) do
if child:IsA("Accessory") then
print("accessory found")
child.Handle.CanTouch = false
child.Handle.CanQuery = false
end
end
end)
How can i make the script wait until the player succesfully loaded?
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if not player:HasAppearanceLoaded() then
player.CharacterAppearanceLoaded:Wait()
end
for _, child in ipairs(character:GetChildren()) do
local handle = child:FindFirstChild("Handle")
if handle then
handle.CanTouch = false
handle.CanQuery = false
end
end
end)
end)
Bare in mind that with your current implementation the touch/query setting would only be executed once (when the player first joins), you would need to wrap code inside of a “.CharacterAdded” event in order for it to be executed each time the player’s character is added (reloads/respawns etc.). Additionally, you don’t need to iterate over the character’s descendants, its children will suffice as accessories are always immediate children.