The goal of my script is to unequip the sword that is equipped when another sword is being equipped. Unexpectedly when I used the FireClient() function, it sent over a nil value for the variable that was being sent to the localscript.
Serverscript
game.ReplicatedStorage.UnequipEvent.OnServerEvent:Connect(function(player, finder)
local location = game.ServerStorage[player.Name]
for i,v in pairs(location.Equipped:GetChildren()) do
v.Parent = location.Unequipped
game.ReplicatedStorage.DataStoreUsage.UnequipOthers:FireClient(player, v) -- FireClient() event
end
game.ServerStorage[player.Name].Unequipped[tostring(finder)].Parent = game.ServerStorage[player.Name].Equipped
end)
Localscript
game.ReplicatedStorage.DataStoreUsage.UnequipOthers.OnClientEvent:Connect(function(v)
print(v) -- returns nil
if v ~= nil then
print("fired")
if player.PlayerGui.ScreenGui.Frame.ScrollingFrame:FindFirstChild(v.Name) then
player.PlayerGui.ScreenGui.Frame.ScrollingFrame[v.Name].Equipped = false
print("fired normal")
else
print("fired sframe2")
player.PlayerGui.ScreenGui.Frame.Sframe2[v.Name].Equipped = false
end
end
end)