i’m not using any arrays at the moment, just basic info, that part of the script works fine.
Are you checking for a specific accessory in a player’s character?
If you checked the script you can understand what im trying to look for, in this case im checking
if cosmetic.Name == child.Name then
cosmetic being what is inside of the player while child is what is inside of the folder im looking thru to check if the name of the child and the cosmetic are the same and if so to not do anything/print() but if the item name isn’t the same then to give the player said item (child)
the issue in this script is that break makes it so the script doesn’t run anything else, im trying to avoid this, if i remove break itll print 5 times because pairs() is running depending on the amount of items found that are similar
Can you explain more about headFolder
?
simple folder containing multiple items, currently only one but i plan on having more than one in the future
here’s all that “headfolder” in other words Cosmetic folder has.
here’s what is sending the Server Event btw
local function onMouseClick(player, click)
local group = click.Parent.Parent.Parent
local head = group:FindFirstChild('Head')
local cosmetic = head:FindFirstChild('Cosmetic')
clickedEvent:FireServer(Character, cosmetic)
--pillarVFXConfig.onVFXPillar(group, timer, true)
warn('mouse called')
end
if curious here’s what happens when you click on the “button”
it completely skips the second part of the script which its supposed to check if the player has the item already
no clue how good this is of a fix but its a fix
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local clickedEvent = ReplicatedStorage:WaitForChild('PillarClicked')
local childChangedEvent = ReplicatedStorage:WaitForChild('childChangedEvent')
local function onClick(player, character, headFolder)
local found = false
for _, child in (headFolder:GetChildren()) do
if child:IsA('Model') or child:IsA('Accessory') then
for _, cosmetic in character:GetDescendants() do
if cosmetic:IsA('Model') or cosmetic:IsA('Accessory') then
if cosmetic.Name ~= child.Name then
print(child.Name, 'not found')
else
print(child.Name, 'found')
found = true
end
end
end
end
end
if not found then
for _, child in (headFolder:GetChildren()) do
if child:IsA('Model') or child:IsA('Accessory') then
local folder = character:FindFirstChild('Unusual_Inventory')
local clone = child:Clone()
local holder = clone:WaitForChild('plh_parent')
childChangedEvent:FireClient(player, child)
clone.Parent = folder
holder.Anchored = true
end
end
end
end
clickedEvent.OnServerEvent:Connect(onClick)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.