I’ve made a UI that fires a server and then the server gives ur guy a helmet, this worked until I went into a local server to test and then for whatever silly reason only 1 player in the server can equip the helmet. And when I unequip from 1 client theotherclient can equip it. Here is helmet giver script:
local events = game.ReplicatedStorage.Clothes:WaitForChild("Events")
local unifs = game.ReplicatedStorage.Clothes
local m1equipped = false
events.PotHelmet.OnServerEvent:Connect(function(plr)
if m1equipped == false then
local clone = unifs.Army.M1PotHelmet:Clone()
clone.Parent = plr.Character
m1equipped = true
elseif m1equipped == true then
plr.Character:FindFirstChild("M1PotHelmet"):Destroy()
m1equipped = false
end
end)
this is because m1equipped is server-side and works as 1 value for all players, instead create a table and enter the names of everyone wearing the helmet.
– i haven’t tested this but I hope it helps
local events = game.ReplicatedStorage.Clothes:WaitForChild(“Events”)
local unifs = game.ReplicatedStorage.Clothes
– Create a dictionary to store the equipped status for each player
local playerEquippedStatus = {}
events.PotHelmet.OnServerEvent:Connect(function(plr)
if not playerEquippedStatus[plr] then
local clone = unifs.Army.M1PotHelmet:Clone()
clone.Parent = plr.Character
playerEquippedStatus[plr] = true
else
local helmet = plr.Character:FindFirstChild(“M1PotHelmet”)
if helmet then
helmet:Destroy()
end
playerEquippedStatus[plr] = false
end
end)
I don’t know if I should but in, but here’s the gist.
Index: The key you input to get a specific value in a table
Boolean: True or false
When you are about to give a player a helmet, you are checking to see if you can find an index that equals to the player in the playerEquippedStatus table. If you cannot, we will make a helmet and add a boolean value with the index of the player.
Sorry if this was very longwinded and hard to understand.