local playerGuns = {
'Starter' == true;
'Shotgun' == false;
'Rifle' == false;
'Burst' == false;
'Heavy' == false;
'Sniper' == false;
'Rocket' == false;
}
for _, v in pairs(playerGuns) do
checkItem:FireServer('Gun', v)
end
checkItem.OnClientEvent:Connect(function(hasItem, item)
if hasItem then
table.insert(playerGuns, item)
end
end)
selectedItem:GetPropertyChangedSignal('Value'):Connect(function()
local hasGun = false
`-- somehow go through table and turn hasGun to true if player has the item with the same name as say a value? selectedItem.Value`
if hasGun then
print('Has the gun unlocked')
else
print('Hasnt got the gun unlocked')
end
end)
I’ve left out all the unnecessary stuff. The remote event works, it fires whenever the local script loads (when player joins, respawns, etc.) When it fires back to the client, it inserts the select ‘item’ into the playerGuns table. I’m having trouble however checking to see if said player has said gun. I’m not sure how I’d loop through the playerGuns table to make sure that they have the same gun as what the selectedItem.Value would be?
Definitely use this way. Then when they have the gun continue what you’re doing by setting it to true.
Then use the instance value’s value to detect whether its true or not.
See with a dictionary as opposed to checking each individual object in the array you can just do this.
local Example = {
["lol"] = true,
["lel"] = false
}
if Example["lol"] then
print("lol") --Prints "lol" to output
else
print("Nope") --Will not Print
end
if Example["lel"] then
print("lel") --Will not Print
else
print("Nope") --Will print "nope" to the output
end